KPL Swing (breakout trading system)

The KPL Swing is a simple trend following mechanical trading system which automates the entry and exit.

The trading system is extremely simple and easy to use, works across multiple time frames and does not require any in-depth knowledge of TA.

The system works with a hard stoploss and a trailing stoploss for exit with profitable trades. No targets are given as no one knows how high (or low) a stock can move. A trailing stoploss locks in the gains and removes emotions from trading.

Limitation: works best with indices and highly liquid stocks. Freak trades can distort the value of the breakout level (high or low).

Code in Metastock and Amibroker AFL is posted at the end of this page.

Delivery trade:

Example charts: Wipro Dly - Asian Paint Dly - Tatamotors Dly - Reliance Weekly

- Use kplswing indicator (N=20) on daily. Use weekly charts if you are a long term investor.
- Initiate a long trade when indicator gives a BUY (stock closes for the first time above the 20 days highest high).
- Keep a "hard stoploss" few points below the Signal date LOW.
- Book profits when indicator gives a SELL (Exit long positions).
- Use position sizing to determine trade quantity...this will automatically limit losses to a predefined value irrespective of stock price.
- Always paper trade before trading with actual cash.

NOTE: the site uses 50% of ATR(20) to calculate the SL and the trade quantity. Feel free to set a deeper stoploss (recalculate trade qtty).

How much quantity to buy? Use position sizing and limit loss to Rs.2,000/- per trade.

Qtty = 2000 / (Purchase price - hard stoploss).

Eg. You want to buy a stock trading at Rs.100/- with a stoploss Rs.90. The quantity you shd trade is 2000/(100-90) = 200 shares. So if your stoploss gets hit, you shd exit and your max loss will be Rs.2,000/-.

Index/ stock futures trade:

Example charts: NIFTY 60min - SBI 60min

- Use kplswing indicator (N=20) on hourly charts.... this roughly corresponds to N=3 on daily charts.
- Trade all long and short signals (once the signal bar is complete).
- Keep a "hard stoploss" few points below from Signal bar LOW for a long trade (above Signal bar HIGH for a short trade).
- If in profit, exit (reverse) position when signal changes.
- Always paper trade before trading with actual cash.

And finally, the code....

Amibroker AFL

_SECTION_BEGIN("KPL Swing");
//Copyright Kamalesh Langote. Email:kpl@vfmdirect.com. More details at http://www.vfmdirect.com/kplswing
//Save indicator as "kplswing.afl" in C: program files > Amibroker > Formulas > Custom folder and then drap and drop on price chart
no=Param( "Swing", 20, 1, 55 );
tsl_col=ParamColor( "Color", colorCycle );

res=HHV(H,no);
sup=LLV(L,no);
avd=IIf(C>Ref(res,-1),1,IIf(C<Ref(sup,-1),-1,0));
avn=ValueWhen(avd!=0,avd,1);
tsl=IIf(avn==1,sup,res);

Plot(tsl, _DEFAULT_NAME(), tsl_col, styleStaircase); // or styleaArea

Buy=Cross(C,Ref(res,-1));
Sell=Cross(Ref(sup,-1),C);
shape=Buy*shapeUpArrow + Sell*shapeDownArrow;
PlotShapes(shape,colorBlack,0,IIf(Buy,Low,High));
_SECTION_END();

Note: the current bar is always dynamic so for intraday purposes, you shd evaluate the signal only after the current bar is complete.

Metastock formula.... note - arrows will not appear in metastock.

{Copyright Kamalesh Langote. Email:kpl@vfmdirect.com More details at http://www.vfmdirect.com/kplswing}
no:=Input("Swing/ Bars", 1, 55, 20);

res:=HHV(H,no);
sup:=LLV(L,no);
avd:=If(C>Ref(res,-1),1,If(C<Ref(sup,-1),-1,0));
avn:=ValueWhen(1,avd<>0,avd);
tsl:=If(avn=1,sup,res);

tsl;