// Downloaded From https://www.WiseStockTrader.com _SECTION_BEGIN("TSKPType1,2,or3setups"); /* TSKPType 1, 2, or 3 setups Type 1 Buy setup Sell setup A higher low is in place A lower high is in place A Blue Arrow below a bar A Red Arrow above a bar The bar is an up or dojii blue bar The bar is an down or dojii red bar A900 above Autostop A900 below Autostop Medium remained blue during the recent retracement Medium remained red during the recent retracement Type 2 Buy setup Sell setup A higher low is in place A lower high is in place A Blue Arrow below a bar A Red Arrow above a bar The bar is an up or dojii blue bar The bar is an down or dojii red bar A900 above Autostop A900 below Autostop Price closed above KPWaterlevel Price closed below KPWaterlevel Medium changed to red during the recent retracement Medium changed to blue during the recent AND was blue at the time when the Blue up arrow retracement AND was red at the time when the red appeared. up arrow appeared. Type 3 Buy setup Sell setup A higher low is in place A lower high is in place A Blue Arrow below a bar A Red Arrow above a bar The bar is an up or dojii blue bar The bar is an down or dojii red bar A900 above Autostop A900 below Autostop Price closed above KPWaterlevel Price closed below KPWaterlevel Medium changed to red during the recent Medium changed to blue during the recent retracement, was still red at the time when the Blue retracement, was still blue at the time when the Red up arrow appeared but above the Moving Average down arrow appeared but below the Moving Average */ SetBarsRequired(350, -0); // ------------- EazyTradePlus V1.1 SetChartOptions(0,chartShowDates|chartWrapTitle); AboveUBB =0; SellSignal=0; BuySignal=0; //--------------------------------EazyTradePlus V1.1 Main AFL SetChartBkColor(ParamColor("Outer panel color ",colorLightYellow)); // color of outer border SetChartBkGradientFill( ParamColor("Inner panel color upper half", colorBlack), ParamColor("Inner panel color lower half", colorDarkOliveGreen)); // color of inner panel //user parameters parmPlotScoreCard = ParamToggle("Plot KPScoreCard", "No|Yes", 1); parmPlotA900AutoStop = ParamToggle("Plot A900/AutoStop", "No|Yes", 0); parmA900Color = ParamColor("A900 Color", colorWhite); parmA900Style = ParamStyle("A900 Style", styleLine, maskAll); parmAutoStopColor = ParamColor("AutoStop Color", colorYellow); parmAutoStopStyle = ParamStyle("AutoStop Style", styleLine, maskAll); parmPPTextColor = ParamColor("PP Text color", colorBlack); parmPPTrndColorUp = ParamColor("PP Trend Up color", ColorRGB(167,224,243) ); parmPPTrndColorDn = ParamColor("PP Trend Dwn color", ColorRGB(255,192,203) ); parmPPTextOffSet = Param("PP OffSet", 0.60, 0.40, 1.5, 0.1); parmTickMultipler = Param("M/W tick allowance", 1, 0, 10, 1); parmA900AutoStopX = ParamToggle("Plot A900/AutoStop Cross", "No|Yes"); parmA900AutoStopColorX = ParamColor("A900/AutoStop Cross Color", colorBlack); ParmSCThreshold = Param("ScoreCard Threshold", 3, 1, 9, 1); parmVoice = ParamToggle("Voice 123 Setups", "No|Yes", 0); parmAlert = ParamToggle("Alert 123 Setups", "No|Yes", 0); parmPivotPop = ParamToggle("PivotPop", "No|Yes", 1); parmBarCancel = Param("Bar Cancel", 7, 1, 20, 1); parmWaterLevelColor = ParamColor("WalterLevel Color", ColorRGB(127,255,212)); parmWaterLevelStyle = ParamStyle("WaterLevel Style", styleLine, maskAll); parmBBPeriod = Param("Bollinger Band Period", 10, 2, 30, 1); parmBBSD = Param("bollinger Band SD", 0.8, 0.2, 3.0); ParmPlotPPIndicators = ParamToggle("Plot Pivot Pop indicators", "No|Yes", 0); parmBBColor = ParamColor("BBands Color", colorBlack); parmBBStyle = ParamStyle("BBands Style", styleLine, maskAll); ParmDebug = ParamToggle("Debug", "No|Yes", 0); // constants _N(PaneName = Name() + Interval(2)+ _SECTION_NAME()); _N(NewBarName = "NewBar" + PaneName); //functions function NewBarP() { PrevDT = StaticVarGet( NewBarName); DT = LastValue(DateTime()); StaticVarSet( NewBarName,DT); return DT != PrevDT; } function MRoundP(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; } //miscellaneous setups ObjAB = CreateObject("Broker.Application"); ticker = objAB.Stocks(Name() ); if(ticker.TickSize == 0) { TickValue = 0.01; //set TickValue to a penney } else { TickValue = ticker.TickSize; // use Tick Size for this symbol } NewBarSignal = NewBarP(); // KP Indicators KPA900 = E_TSKPA900(Close); KPAutoStop = E_TSKPAUTOSTOP(High,Low,Close); 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); if(parmDebug == 1) { printf("a900: %0.6f% \nAutoStop: %0.6f%\nScoreCard: %0.0f%\n", KPA900, KPAutoStop, KPScoreCard); } if(parmPlotScoreCard == 1) { _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g% (%0.4f%) {{VALUES}}", O, H, L, C, SelectedValue( C - Ref(C, -1)) )); if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) ) { ToolTip=StrFormat("Open: %g\nHigh: %g\nLow: %g\nClose: %g (%.2f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 ))); } Color = IIf(KPScoreCard >= parmSCThreshold, colorBlue, IIf(KPScoreCard <= -parmSCThreshold, colorRed, colorYellow) ); Plot( C, "Close", Color , styleNoTitle | ParamStyle("OHLC Style",styleBar | styleThick) | GetPriceStyle() ); } //user want A900/AutoStop plotted if(parmPlotA900AutoStop == 1) { Plot(KPA900, "A900", parmA900Color, parmA900Style); Plot(KPAutoStop, "AutoStop", parmAutoStopColor, parmAutoStopStyle); } // find A900/AutoStop cross over/under with ScoreCard confirmation. XOUp = (KPA900 > KPAutoStop) AND (KPScoreCard >= parmSCThreshold); // New Pivot Low XODn = (KPA900 < KPAutoStop) AND (KPScoreCard <= -parmSCThreshold); // New Pivot High if(parmDebug == 1) { printf(WriteIf(XOUp, "before= XOUp: True", "before= XOUp: False") + WriteIf(XODn, " XODn: True\n", " XODn: False\n") ); } //remove duplicate signals XOUp = ExRem(XOUp, XODn); XODn = ExRem(XODn, XOUp); if(parmDebug == 1) { printf(WriteIf(XOUp, "after= XOUp: True", "after= XOUp: False") + WriteIf(XODn, " XODn: True\n", " XODn: False\n") ); } //find the current Pivot Points - PL and PH //remember XOUp = 1 means a PL and XODn =1 means a PH PLBars = IIf(XOUp, LowestSinceBars(XODn, L ,1), 0); //find the bar that produced the Lowest Low PHBars = IIf(XODn, HighestSinceBars(XOUp, H, 1),0); //find the bar that produced the Highest High //PLPrice = IIf(XOUp, Ref(L, -PLBars), 0); //PHPrice = IIf(XODn, Ref(H, -PHBars),0); PLPrice = Ref(L, -PLBars); PHPrice = Ref(H, -PHBars); //keep track of the previous Pivot Points PrevPLBars = Ref(BarsSince(XOUp), -1) +1; PrevPHBars = Ref(BarsSince(XODn), -1) +1; PrevPLPrice = Ref(PLPrice, -prevPLBars); PrevPHPrice = Ref(PHPrice, -PrevPHBars ); PivotsCloseEnough = TickValue * parmTickMultipler; PLDifference = MroundP(PLPrice - PRevPLPrice, ticker.TickSize); PHDifference = MroundP(PHPrice - PrevPHPrice, ticker.TickSize); PPTrend = IIf(XOUp AND (PLDifference > PivotsCloseEnough) AND PrevPHPrice > PrevPLPrice AND PRevPHPrice > PLPrice, 1, IIf(XOUp AND (PLDifference < - PivotsCloseEnough) AND PRevPHPrice > PrevPLPrice AND PrevPHPrice > PLPrice, -1, IIf(XODn AND (PHDifference > PivotsCloseEnough) AND PrevPLPrice < PrevPHprice AND PrevPLPrice < PHPrice, 1, IIf(XODn AND (PHDifference < -PivotsCloseEnough) AND PrevPLPrice < PrevPHPrice AND PrevPLPrice < PHPrice, -1, IIf(XOUp AND (abs(PLDifference) <= PivotsCloseEnough) AND PrevPHPrice > PrevPLPrice AND PRevPHPrice > PLPrice, 2, IIf(XODn AND (abs(PHDifference) <= PivotsCloseEnough) AND PrevPLPrice < PrevPHPrice AND PrevPLPrice < PHPrice, -2, 0)))) )); if(ParmDebug) { printf("Current PH Bar: %g% /Price: %g%\n", PHBars, PHPrice); printf("Current PL Bar: %g% /Price: %g%\n", PLBars, PLPrice); printf("Previous PH Bar: %g% /Price: %g%\n", PrevPHBars, PrevPHPrice); printf("Previous PL Bar: %g% /Price: %g%\n", PrevPLBars, PrevPLPrice) ; printf("PP Trend: %g%\n", PPTrend); printf("PHPrice - PrevPHPrice: %g%\nPLPrice - PrevPLPrice: %g%\nPivotsCloseEnough: %g%", PHDifference, PLDifference, PivotsCloseEnough); } //PLot pivots as text dist = parmPPTextOffSet * ATR(10); //for( i = 0; i < BarCount -1; i++) for( i = 0; i < BarCount ; i++) { if(XOUp[i ] == 1 AND abs(PPTrend[i]) != 2) //cross up -plot the Pivot Low { PlotText("PL", i - PLBars[i], PLPrice[i] - dist[i] , parmPPTextColor, IIf(PPTrend[i] == 1, parmPPTrndColorUp, IIf(PPTrend[i] == -1, parmPPTrndColorDn, colorYellow) )); } if(XODn[i ] == 1 AND abs(PPTrend[i]) != 2) //cross down - plot the pivot high { PlotText("PH", i - PHBars[i], PHPrice[i] + dist[i], parmPPTextColor, IIf(PPTrend[i] == 1, parmPPTrndColorUp, IIf(PPTrend[i] == -1, parmPPTrndColorDn, colorYellow) )); } if(XOUp[i ] == 1 AND (PPTrend[i]) == 2) // the Pivot Low is a W Bottom { PlotText("PW", i - PLBars[i], PLPrice[i] - dist[i] , parmPPTextColor, colorYellow) ; } if(XODn[i ] == 1 AND PPTrend[i] == -2) //cross down - pivot high is a M Top { PlotText("PM", i - PHBars[i], PHPrice[i] + dist[i], parmPPTextColor, colorYellow) ; } } //end For // Plot A900/AutoStop cross over/under if(parmA900AutoStopX == 1) { PlotShapes(IIf(Cross(KPA900, KPAutoStop), shapeUpTriangle, shapeNone), parmA900AutoStopColorX, 0, L, -30); PlotShapes(IIf(Cross(KPAutoStop, KPA900), shapeDownTriangle, shapeNone), parmA900AutoStopColorX, 0, H , -30); } //PHLine = LineArray(BarCount - LastValue(PHBars) -3, LastValue(PHPrice), BarCount - LastValue(PHBars) +2, LastValue(PHPrice), 0); //Plot(PHLine, "PH", colorBlack, styleLine); //PLLine = LineArray(BarCount - LastValue(PLBars) -3, LastValue(PLPrice), BarCount - LastValue(PLBars) +2, LastValue(PLPrice), 0); //Plot(PLLine, "PL", colorBlack, styleLine); // identify M, lazy M, W and Lazy W formations //Pivot Pop code if(parmPivotPop == 1) { //Kp indicators for Pivot Pop dummy = E_TSKPFAST2(Open, High, Low, Close, Volume); KPFast2 = IIf(tskp_fast2val1 > 0, 1, -1); //calculations BarsSinceXOUp =BarsSince(XOUp); BarsSinceXODn = BarsSince(XODn); UBB = BBandTop(C, parmBBPeriod, parmBBSD); LBB = BBandBot(C, parmBBPeriod, parmBBSD); PopFilter = True; if(parmDebug == 1) { printf("\nFast2: %1.0f% \nUBB: %0.6f%\nLBB: %0.6f%\nC: %g%\n", KPFast2, UBB, LBB, C); printf("Bars since Last XOUp: %1.0f%\nBars since last XODn: %1.0f%\n", BarsSinceXOUp, BarsSinceXODn ); printf("Bars since PPTrnd =1: %1.0f%\nBars since PPTrnd = -1: %1.0f%\n", BarsSince(PPTrend ==1), BarsSince(PPTrend == -1) ); } PPopUp = (BarsSince(PPTrend >= 1) < BarsSince(PPTrend <= -1)) AND (BarsSince(XOUp) <= parmBarCancel) AND (KPA900 >= KPAutoStop) AND(KPFast2 == 1) AND (KPScoreCard >= 5) AND PopFilter AND (C > UBB) AND (C > O) ; PPopUp = IIf( PPopUp AND Sum(PPopUP, BarsSince(XOUp)+1) == 1, True, False ); //keep only the 1st signal PPopDn = (BarsSince(PPTrend <= -1) < BarsSince(PPTrend >= 1)) AND (BarsSince(XODn) <= parmBarCancel) AND (KPA900 <= KPAutoStop) AND(KPFast2 == -1) AND (KPScoreCard <= -5) AND PopFilter AND (C < LBB) AND (C < O) ; PPopDn = IIf( PPopDn AND Sum(PPopDn, BarsSince(XODn) + 1) == 1, True, False); //keep only the first signal if(parmDebug == 1) { printf(WriteIf(PPopUp,"PPopUp: True", "PPopUp: False") + WriteIf(PPopDn, " PPopDn: True\n", " PPopDn: False\n") ); printf("PPopUp sum: %1.0f% \nPPopDn sum: %1.0f%\n", Sum(PPopUP, BarsSince(XOUp)) , Sum(PPopDn, BarsSince(XODn)) ); } // Plots PlotShapes(IIf(PPopUp, shapeHollowUpArrow, shapeNone), colorDarkBlue, 0, L, -25); PlotShapes(IIf(PPopDn, shapeHollowDownArrow, shapeNone), colorDarkRed, 0, H, -25); if(ParmPlotPPIndicators == 1) //plot the Pivot Pop Indicators { Plot(UBB, "Upper BB", parmBBColor, parmBBStyle); Plot(LBB, "Lower BB", parmBBColor, parmBBStyle); if(parmPlotA900AutoStop == 1) { Plot(KPA900, "A900", parmA900Color, parmA900Style); Plot(KPAutoStop, "AutoStop", parmAutoStopColor, parmAutoStopStyle); } Plot( 0.5, "Fast2", IIf(tskp_fast2val1 > 0, parmPPTrndColorUp, parmPPTrndColorDn) , styleArea | styleNoLabel | styleOwnScale , 0, 10); } //endif parmPlotPPIndicators } // end if parmPivotPop // Type 1, 2 or 3 setups // kp indicators KPWaterlevel = E_TSKPWATERLEVEL(Open,High,Low,Close,Volume); dummy = E_TSKPMEDIUM(Close); KPMediumUp = tskp_mediumup; KPMediumDn = tskp_mediumdown; KPMediumMA = tskp_mediumma; KPMedium = KPMediumUp + KPMediumDn; //calculations PLBars = IIf(XOUp, LowestSince(XODn, KPMedium ,1), 0); //find the Lowest Low PHBars = IIf(XODn, HighestSinceBars(XOUp, KPMedium, 1),0); //find the bar that produced the Highest High PrevPLMedium = Ref(KPMedium, -prevPLBars); PrevPHMedium = Ref(KPMEdium, -PrevPHBars ); Type1Filter = IIf(PPopUp AND (LowestSince(XODn, KPMedium, 1) > 0 ) AND (HighestSince(XODn, KPMedium, 1) > 0 ), True, IIf(PPopDn AND (HighestSince(XOUp, KPMedium ,1) < 0) AND (LowestSince(XOUp, KPMedium ,1) < 0), True, False)); Type2Filter = IIf(PPopUp AND LowestSince(XODn, KPMedium, 1) < 0 AND KPMedium > 0, True, IIf(PPopDn AND (HighestSince(XOUp, KPMedium ,1) > 0) AND KPMEdium < 0, True, False)); Type3Filter = IIf(PPopUp AND LowestSince(XODn, KPMedium, 1) < 0 AND KPMedium < 0 AND (KPMedium > KPMediumMA), True, IIf(PPopDn AND (HighestSince(XOUp, KPMedium ,1) > 0) AND KPMEdium > 0 AND(KPMedium < KPMediumMA), True, False)); Type1Buy = PPopUp AND ((Close - Open) >= 0) AND (KPScoreCard >= ParmSCThreshold) AND Type1Filter; Type1Sell = PPopDn AND ((Close - Open) <= 0) AND (KPScoreCard <= -ParmSCThreshold) AND Type1Filter; Type2Buy = PPopUp AND ((Close - Open) >= 0) AND (KPScoreCard >= ParmSCThreshold) AND Type2Filter AND C > KPWaterLevel; Type2Sell = PPopDn AND ((Close - Open) <= 0) AND (KPScoreCard <= -ParmSCThreshold) AND Type2Filter AND C < KPWaterLevel; Type3Buy = PPopUp AND ((Close - Open) >= 0) AND (KPScoreCard >= ParmSCThreshold) AND Type3Filter AND C > KPWaterLevel; Type3Sell = PPopDn AND ((Close - Open) <= 0) AND (KPScoreCard <= -ParmSCThreshold) AND Type3Filter AND C < KPWaterLevel; if(parmDebug == 1) { printf("Type1Filter: %g%\nType2Filter: %g%\nType3Filter: %g%\n", Type1Filter, Type2Filter, Type3Filter); printf("KPWaterlevel: %g%\n", KPWaterLevel); printf("KPMedium: %g%\nKPMediumMA: %g%\n", KPMedium, KPMediumMA); printf("Highest XOUp Medium: %g%\nLowest XOUp Medium: %g%\n", HighestSince(XOUp, KPMedium, 1), LowestSince(XOUp, KPMedium ,1) ); printf("Highest XODn Medium: %g%\nLowest XODn Medium: %g%\n", HighestSince(XODn, KPMedium, 1), LowestSince(XODn, KPMedium ,1) ); printf("Prev PH Medium: %g%:Prev PL Medium: %g%\n", PrevPHMedium, PrevPLMedium); printf("Type1Buy: %g%:Type1Sell: %g%\n", Type1Buy, Type1Sell); printf("Type2Buy: %g%:Type2Sell: %g%\n", Type2Buy, Type2Sell); printf("Type3Buy: %g%:Type3Sell: %g%\n", Type3Buy, Type3Sell); } // Plots PlotShapes(IIf(Type1Buy, shapeDigit1 , IIf(Type1Sell, shapeDigit1, shapeNone)), IIf(Type1Buy, colorBlue, IIf(Type1Sell, colorRed, Null)), 0, IIf(Type1Buy, High, IIf(Type1Sell, L, O)), IIf(Type1Buy, 30, IIf(Type1Sell, -30, 0)) ); PlotShapes(IIf(Type2Buy, shapeDigit2 , IIf(Type2Sell, shapeDigit2, shapeNone)), IIf(Type2Buy, colorBlue, IIf(Type2Sell, colorRed, Null)), 0, IIf(Type2Buy, High, IIf(Type2Sell, L, O)), IIf(Type2Buy, 30, IIf(Type2Sell, -30, 0)) ); PlotShapes(IIf(Type3Buy, shapeDigit3 , IIf(Type3Sell, shapeDigit3, shapeNone)), IIf(Type3Buy, colorBlue, IIf(Type3Sell, colorRed, Null)), 0, IIf(Type3Buy, High, IIf(Type3Sell, L, O)), IIf(Type3Buy, 30, IIf(Type3Sell, -30, 0)) ); Plot(KPWaterLevel, "KPWaterLevel", parmWaterLevelColor, parmWaterLevelStyle); // HMM how to print Medium on a price chart //voice if(parmVoice ==1) { if(NewBarSignal) { if( LastValue(Ref(Type1Buy, -1)) == 1) Say(Interval(2) + " New Type one buy."); if( LastValue(Ref(Type2Buy, -1)) == 1) Say(Interval(2) + " New Type two buy"); if( LastValue(Ref(Type3Buy, -1)) == 1) Say(Interval(2) + " New Type three buy."); if( LastValue(Ref(Type1Sell,-1)) ==1) Say(Interval(2) + " New Type one sell."); if( LastValue(Ref(Type2Sell,-1)) ==1) Say(Interval(2) + " New Type two sell."); if( LastValue(Ref(Type3Sell,-1)) ==1) Say(Interval(2) + " New Type three sell."); } } //alerts if(parmAlert ==1) { AlertIf(NewbarSignal AND Ref(Type1Buy, -1), "", "Type 1 Buy.", 1, 15, 0); AlertIf(NewbarSignal AND Ref(Type2Buy, -1), "", "Type 2 Buy.", 1, 15, 0); AlertIf(NewbarSignal AND Ref(Type3Buy, -1), "", "Type 3 Buy.", 1, 15, 0); AlertIf(NewbarSignal AND Ref(Type1Sell, -1), "", "Type 1 Sell.", 2, 15, 0); AlertIf(NewbarSignal AND Ref(Type2Sell, -1), "", "Type 2 Sell.", 2, 15, 0); AlertIf(NewbarSignal AND Ref(Type3Sell, -1), "", "Type 3 Sell.", 2, 15, 0); } _SECTION_END(); _SECTION_BEGIN("ABKPPowerPops"); /* 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", styleLine | styleDots | styleStaircase, 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() ); 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", TriggOsc, 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) - ticker.TickSize, Ref(H, - BarDnSince) + ticker.TickSize); if(LastValue(Ref(UpSignal, -1)) ) Say(Interval(2) + " Power pop: up. Stop at " + NumToStr(Ref(L, -1) - ticker.TickSize, 1.2) + "."); if(LastValue(Ref(DnSignal, -1)) ) Say(Interval(2) + " Power pop: down. Stop at " + NumToStr(Ref(H, -1) + ticker.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_END(); _SECTION_BEGIN("ABKPSEB"); /* Standard Error Bands */ // user parameters Periods = Param("Standard Error", 80, 1, 200, 1); Smooth = Param("Smooth",14,2,100,1); parmMBColor = ParamColor("Color MB",colorPlum); parmMBStyle = ParamStyle("Style MB", style=styleDashed | styleNoLabel, Mask=maskAll ); parmUBColor = ParamColor("Color UB",colorDarkRed); parmUBStyle = ParamStyle("Style UB", style=styleLine | styleNoLabel, Mask=maskAll ); parmLBColor = ParamColor("Color LB",colorDarkRed); parmLBStyle = ParamStyle("Style LB", style=styleLine | styleNoLabel, Mask=maskAll ); ParmCloud = ParamToggle("Cloud", "No|Yes", 0); parmCloudColor = ParamColor("Cloud Color", ColorRGB( 40,40,40) ); ParmField = ParamField("Field", -1); parmTT = ParamToggle("Plot Tone/Trend", "No|Yes", 0); parmToneColorUp = ParamColor("Tone Color Up", ColorRGB(167, 224, 243) ); parmToneColorDn = ParamColor("Tone Color Dn", ColorRGB(255, 192, 203) ); parmTrendColorUp = ParamColor("Trend Color Up", ColorRGB(167, 224, 243) ); parmTrendColorDn = ParamColor("Trend Color Dn", ColorRGB(255, 192, 203) ); RibbonSize = Param("Ribbon Size", 1 , 0.5, 10, 0.5); SetBarsRequired(700, -1); // calculations LRCurve = LinearReg( ParmField, periods ); MALRCurve = MA(LRCurve, Smooth); SEValue = StdErr( ParmField, periods ); SErrorAvg = MA(SEValue, Smooth); LowerBand = MALRCurve - SErrorAvg ; UpperBand = MALRCurve + SErrorAvg ; Plot( MALRCurve , "MidBand", parmMBColor , parmMBStyle); Plot( UpperBand , "UpperBand",parmUBColor ,parmUBStyle ); Plot( LowerBand , "LowerBand", parmLBColor , parmLBStyle); //paint inside the bands if(parmCloud == 1) { PlotOHLC( UpperBand, UpperBand, LowerBand, LowerBand, "Band", parmCloudColor, styleCloud | styleNoLabel); } //paint tone and trend if(parmTT == 1) { PlotOHLC( UpperBand, UpperBand, LowerBand, LowerBand, "Band", IIf(Low > UpperBand, parmTrendColorUp, IIf(High < LowerBand, parmTrendColorDn, parmCloudColor)) , styleCloud | styleNoLabel); Plot( RibbonSize, "Tone", IIf(Close > MALRCurve, parmToneColorUp, parmToneColorDn) , styleArea | styleNoLabel | styleOwnScale , 0, 10); }