// Downloaded From https://www.WiseStockTrader.com _SECTION_BEGIN("KPL Swing with N&M Swing"); SetBarsRequired(200,0); GraphXSpace = 5; SetChartOptions(0,chartShowArrows|chartShowDates); k = Optimize("K",Param("K",3.0,0.25,5,0.25),0.25,5,0.25); Per= Optimize("atr",Param("atr",10,3,20,1),3,20,1); HACLOSE=(O+H+L+C)/4; HaOpen = AMA( Ref( HaClose, -1 ), 0.5 ); HaHigh = Max( H, Max( HaClose, HaOpen ) ); HaLow = Min( L, Min( HaClose, HaOpen ) ); PlotOHLC( HaOpen, HaHigh, HaLow, HaClose, "" + Name(), colorBlack, styleCandle | styleNoLabel ); j=Haclose; //======================================================================================================================= //=========================Indicator============================================================================================== f=ATR(15); rfsctor = WMA(H-L, Per); revers = k * rfsctor; Trend = 1; NW[0] = 0; NW[BarCount-1] = Null; for(i = 1; i < BarCount-1; i++) { if(Trend[i-1] == 1) { if(j[i] < NW[i-1]) { Trend[i] = -1; NW[i] = j[i] + Revers[i]; } else { Trend[i] = 1; if((j[i] - Revers[i]) > NW[i-1]) { NW[i] = j[i] - Revers[i]; } else { NW[i] = NW[i-1]; } } } if(Trend[i-1] == -1) { if(j[i] > NW[i-1]) { Trend[i] = 1; NW[i] = j[i] - Revers[i]; } else { Trend[i] = -1; if((j[i] + Revers[i]) < NW[i-1]) { NW[i] = j[i] + Revers[i]; } else { NW[i] = NW[i-1]; } } } } //===============system================ Plot(NW, "", IIf(Trend == 1, 27, 4), 4); Buy=NWHACLOSE; SellPrice=ValueWhen(Sell,C,1); BuyPrice=ValueWhen(Buy,C,1); Buy=ExRem(Buy,Sell); Sell=ExRem(Sell,Buy ); Short=Sell; Cover=Buy; NMAB= NWHACLOSE; AlertIf( Buy , "SOUND C://Windows//Media//chimes.wav", "Audio alert", 2 ); AlertIf( Sell , "SOUND C://Windows//Media//alert.wav", "Audio alert", 2 ); NMA_status= WriteIf(NMAB, "BUY MODE", WriteIf(NMAS, "SELL MODE", "NEUTRAL")); NMAS_Col=IIf(NMAB, colorGreen, IIf(NMAS, colorRed, colorLightGrey)); Filter=1; AddColumn( NW[BarCount-1], "SAR", 1.2 ); AddColumn( HACLOSE, "HA Close", 1.2 ); AddColumn( C, "Close", 1.2 ); AddTextColumn(NMA_status, "MODE", 1, colorWhite, NMAS_Col); AddColumn( DateTime(), "Date / Time", formatDateTime ); _SECTION_END(); _SECTION_BEGIN("Title"); if( Status("action") == actionIndicator ) ( Title = EncodeColor(colorWhite)+ "SureShot trading 3 10" + " - " + Name() + " - " + EncodeColor(colorRed)+ Interval(2) + EncodeColor(colorWhite) + " - " + Date() +" - "+"\n" +EncodeColor(colorRed) +"Op-"+O+" "+"Hi-"+H+" "+"Lo-"+L+" "+ "Cl-"+C+" "+ "Vol= "+ WriteVal(V)+"\n"+ EncodeColor(colorLime)+ WriteIf (Buy , " GO LONG / Reverse Signal at "+C+" ","")+ WriteIf (Sell , " EXIT LONG / Reverse Signal at "+C+" ","")+"\n"+EncodeColor(colorWhite)+ WriteIf(Sell , "Total Profit/Loss for the Last Trade Rs."+(C-BuyPrice)+"","")+ WriteIf(Buy , "Total Profit/Loss for the Last trade Rs."+(SellPrice-C)+"","")); //WriteIf(Long AND NOT Buy, "Trade : Long - Entry price Rs."+(BuyPrice),"")+ //WriteIf(shrt AND NOT Sell, "Trade : Short - Entry price Rs."+(SellPrice),"")+"\n"+ //WriteIf(Long AND NOT Buy, "Current Profit/Loss Rs."+(C-BuyPrice)+"","")+ //WriteIf(shrt AND NOT Sell, "Current Profit/Loss Rs."+(SellPrice-C)+"","")); PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40); PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50); PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45); PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40); PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50); PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45); for(i=BarCount-1;i>1;i--) { if(Buy[i] == 1) { entry = H[i]; sig = "BUY"; sl = Ref(NW,-1); tar1 = entry + (entry * .0050); tar2 = entry + (entry * .0092); tar3 = entry + (entry * .0179); bars = i; i = 0; } if(Sell[i] == 1) { sig = "SELL"; entry = L[i]; sl = Ref(NW,-1); tar1 = entry - (entry * .0050); tar2 = entry - (entry * .0112); tar3 = entry - (entry * .0212); bars = i; i = 0; } } Offset = 20; Clr = IIf(sig == "BUY", colorLime, colorRed); ssl = IIf(bars == BarCount-1, NW[BarCount-1], Ref(NW, -1)); sl = ssl[BarCount-1]; Plot(LineArray(bars-Offset, tar1, BarCount, tar1,1), "", Clr, styleLine|styleDots, Null, Null, Offset); Plot(LineArray(bars-Offset, tar2, BarCount, tar2,1), "", Clr, styleLine|styleDots, Null, Null, Offset); Plot(LineArray(bars-Offset, tar3, BarCount, tar3,1), "", Clr, styleLine|styleDots, Null, Null, Offset); messageboard = ParamToggle("Message Board","Show|Hide",1); if (messageboard == 1 ) { GfxSelectFont( "Tahoma", 13, 100 ); GfxSetBkMode( 1 ); GfxSetTextColor( colorWhite ); if ( sig =="BUY") { GfxSelectSolidBrush( colorBlue ); // this is the box background color } else { GfxSelectSolidBrush( colorRed ); // this is the box background color } pxHeight = Status( "pxchartheight" ) ; xx = Status( "pxchartwidth"); Left = 1100; width = 310; x = 5; x2 = 290; y = pxHeight; GfxSelectPen( colorGreen, 1); // broader color GfxRoundRect( x, y - 98, x2, y , 7, 7 ) ; GfxTextOut( ( "SureShot Trading System"),13,y-100); GfxTextOut( (" "),27,y-100); GfxTextOut( ("Last " + sig + " Signal came " + (BarCount-bars-1) * Interval()/60 + " mins ago"), 13, y-80) ; // The text format location GfxTextOut( ("" + WriteIf(sig =="BUY",sig + " @ ",sig + " @") + " : " + entry), 13, y-60); GfxTextOut( ("Trailing SL : " + sl + " (" + WriteVal(IIf(sig == "SELL",entry-sl,sl-entry), 2.2) + ")"), 13, y-40); /*GfxTextOut( ("TGT:1 : " + tar1), 13, y -80); GfxTextOut( ("TGT:2 : " + tar2), 13,y-60); GfxTextOut( ("TGT:3 : " + tar3), 13,y-40);*/ GfxTextOut( ("Current P/L : " + WriteVal(IIf(sig == "BUY",(C-entry),(entry-C)),2.2)), 13, y-22); } _SECTION_END(); _SECTION_BEGIN("Fib Retracements"); fibs = ParamToggle("Plot Fibs","Off|On",1); pctH = Param ("Pivot Hi %", 0.325,0.001,2.0,0.002); HiLB = Param ("Hi LookBack",1,1,BarCount-1,1); pctL = Param ("Pivot Lo %", 0.325,0.001,2.0,0.002); LoLB = Param ("Lo LookBack",1,1,BarCount-1,1); Back = Param ("Extend Left = 2",1,1,500,1); Fwd = Param("Plot Forward", 0, 0, 500, 1); text = ParamToggle("Plot Text","Off|On",1); hts = Param ("Text Shift", -33.5,-50,50,0.10); style =ParamStyle("Line Style",styleLine,styleNoLabel); x = BarIndex(); pRp = PeakBars( H, pctH, 1) == 0; yRp0 = LastValue(ValueWhen( pRp, H, HiLB)); xRp0 = LastValue(ValueWhen( pRp, x, HiLB)); pSp = TroughBars( L, pctL, 1) == 0; ySp0 = LastValue(ValueWhen( pSp, L, LoLB)); xSp0 = LastValue(ValueWhen( pSp, x, LoLB)); Delta = yRp0 - ySp0; function fib(ret) { retval = (Delta * ret); Fibval = IIf(ret < 1.0 AND xSp0 < xRp0, yRp0 - retval, IIf(ret < 1.0 AND xSp0 > xRp0, ySp0 + retval,IIf(ret > 1.0 AND xSp0 < xRp0, yRp0 - retval, IIf(ret > 1.0 AND xSp0 > xRp0, ySp0 + retval, Null)))); return FibVal; } x0 = Min(xSp0,xRp0)-Back; x1 = (BarCount -1); ////////////////////////////////////////////////////////////////// r236 = fib(0.236); r236I = LastValue (r236,1); r382 = fib(0.382); r382I = LastValue (r382,1); r050 = fib(0.50); r050I = LastValue (r050,1); r618 = fib(0.618); r618I = LastValue (r618,1); r786 = fib(0.786); r786I = LastValue (r786,1); e127 = fib(1.27); e127I = LastValue (e127,1); e162 = fib(1.62); e162I = LastValue (e162,1); e200 = fib(2.00); e200I = LastValue (e200,1); e262 = fib(2.62); e262I = LastValue (e262,1); e424 = fib(4.24); e424I = LastValue (e424,1); ////////////////////////////////////////////////////////////////// p00 = IIf(xSp0 > xRp0,ySp0,yRp0); p00I = LastValue (p00,1); p100 = IIf(xSp0 < xRp0,ySp0,yRp0); p100I = LastValue (p100,1); color00 =IIf(xSp0 > xRp0,colorLime,colorRed); color100 =IIf(xSp0 < xRp0,colorLime,colorRed); ////////////////////////////////////////////////////////////////// numbars = LastValue(Cum(Status("barvisible"))); fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2); ////////////////////////////////////////////////////////////////// if(fibs==1) { Plot(LineArray(xRp0-Fwd,yRp0,x1,yRp0,Back),"PR",32,styleThick | styleNoRescale | styleNoLabel | styleNoTitle,Null, Null,Fwd); Plot(LineArray(xSp0-Fwd,ySp0,x1,ySp0,Back),"PS",27, styleThick | styleNoRescale | styleNoLabel | styleNoTitle,Null, Null,Fwd); Plot(LineArray(x0-Fwd,r236,x1,r236,Back),"",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd); Plot(LineArray(x0-Fwd,r382,x1,r382,Back),"",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd); Plot(LineArray(x0-Fwd,r050,x1,r050,Back),"",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd); Plot(LineArray(x0-Fwd,r618,x1,r618,Back),"",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd); Plot(LineArray(x0-Fwd,r786,x1,r786,Back),"",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd); Plot(LineArray(x0-Fwd,e127,x1,e127,Back),"e127",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd); Plot(LineArray(x0-Fwd,e162,x1,e162,Back),"e162",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd); Plot(LineArray(x0-Fwd,e200,x1,e200,Back),"p200",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd); Plot(LineArray(x0-Fwd,e262,x1,e262,Back),"p262",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd); Plot(LineArray(x0-Fwd,e424,x1,e424,Back),"p424",colorBlack,style|styleNoRescale | styleNoLabel | styleDashed,Null, Null,Fwd); } ////////////////////////////////////////////////////////////////// if(text==1) { PlotText(" 0% = " + WriteVal(p00,fraction), LastValue(BarIndex())-(numbars/hts), p00I + 0.05, colorDarkGreen); PlotText("23% = " + WriteVal(r236,fraction), LastValue(BarIndex())-(numbars/hts), r236I + 0.05, colorBlack); PlotText("38% = " + WriteVal(r382,fraction), LastValue(BarIndex())-(numbars/hts), r382I + 0.05, colorBlack); PlotText("50% = " + WriteVal(r050,fraction), LastValue(BarIndex())-(numbars/hts), r050I + 0.05, colorBlack); PlotText("62% = " + WriteVal(r618,fraction), LastValue(BarIndex())-(numbars/hts), r618I + 0.05, colorBlack); PlotText("78% = " + WriteVal(r786,fraction), LastValue(BarIndex())-(numbars/hts), r786I + 0.05, colorBlack); PlotText("100% = " + WriteVal(p100,fraction), LastValue(BarIndex())-(numbars/hts),p100I + 0.05, colorDarkRed); PlotText("127% = " + WriteVal(e127,fraction), LastValue(BarIndex())-(numbars/hts),e127I + 0.05, colorBlack); PlotText("162% = " + WriteVal(e162,fraction), LastValue(BarIndex())-(numbars/hts),e162I + 0.05, colorBlack); PlotText("200% = " + WriteVal(e200,fraction), LastValue(BarIndex())-(numbars/hts),e200I + 0.05, colorBlack); PlotText("262% = " + WriteVal(e262,fraction), LastValue(BarIndex())-(numbars/hts),e262I + 0.05, colorBlack); PlotText("424% = " + WriteVal(e424,fraction), LastValue(BarIndex())-(numbars/hts),e424I + 0.05, colorBlack); } _SECTION_END();