Trading with TSMA (Trailing Stop Moving Average) System

findvikas

Well-Known Member
#1
I had been working on couple of systems and back testing the results... here is another such experimental system.

PLEASE DO NOT TRADE THIS SYSTEM AS THIS IS JUST FOR THE SAKE OF TESTING AND SUGGESTIONS TO MAKE IT BETTER.

What it is all about?
It is the simplest form of Moving Average system which does not look for a cross to enter the trade but compare the current bar's closing price and if the current price trade above the MA then its a Buy and if it comes below the MA then its a sell.

I have seen many MA systems and the biggest problem with them is that they are too slow in predicting the change in trend that mostly when you came to know that trend has changed its too late and you are near cost.


Basically this system is a fusion of these two previous experiments and try to compliment each other
MA System - http://www.traderji.com/options/32712-my-daily-options-trading-diary.html#post357626
Trailing Stop Loss System - http://www.traderji.com/futures/35679-nifty-technicals.html#post386706


What is the strategy?
Get out of the winning trade on a first sign of reversal in trend and stay out with the cash.

How it works?
You choose a MA period... default is 21 (my favorite Fibo level and works best on most chart periods)
You choose a Shift period.. to decide the Training Stop Loss (idea taken from Nifty Technicals System)

Buy Setup: Current bar is third consecutive bar above MA(period)
Buy Stop: Last N bar's close price

Sell Setup: Current bar is third consecutive bar above MA(period)
Sell Stop: Last N bar's close price

Back tester's Settings



Parameters



System on Daily Chart of Nifty Futures

 
Last edited:

findvikas

Well-Known Member
#2
Trailing Stop Moving Average System's AFL

Last Updated: 2/24/2010


_SECTION_BEGIN("TSMA System");
SetChartOptions(0,chartShowArrows|chartShowDates);
SetChartBkGradientFill(colorWhite,colorRose,colorYellow);

_N(Title = StrFormat("Vikas's Trailing Stop MA System - {{NAME}} - {{INTERVAL}} {{DATE}} \nOpen %g, \nHigh %g, \nLow %g, \nClose %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

M1 = MA(C,Param("MA",21,1));
shiftStop = Param("Shift Stop",3);

Buy = (C > M1) AND (Ref(C,-1) > M1) AND (Ref(C,-2) > M1);
BuyStop = Buy AND C<Ref(C,-shiftStop);

Sell = (C < M1) AND (Ref(C,-1) < M1) AND (Ref(C,-2) < M1);
SellStop = Sell AND C>Ref(C,-shiftStop);

Plot(M1,"\nMoving Average",colorTeal,styleThick);
Plot(Ref(C,-1),"\nPrevious Close",colorRed,styleNoDraw);
Plot(Ref(C,-2),"P2P Close",colorRed,styleNoDraw | styleNoDraw);
Plot(Ref(C,-shiftStop),"\nStop Loss",colorRed, styleDashed | styleThick | styleNoDraw);




Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
BuyStop = ExRem(BuyStop,SellStop);
SellStop = ExRem(SellStop,BuyStop);


Short = Sell;
Cover=Buy;

ChartStyle = styleCandle | styleThick | styleNoTitle;

PlotOHLC(O,H,L,C,Name(),colorDefault, ChartStyle);

// -- OK, let's plot the signals using arrows

PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-20);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-30);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-25);

PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=20);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=30);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-25);


PlotShapes(IIf(BuyStop, shapeUpArrow, shapeNone),colorGreen, 0,L, Offset=-10);
PlotShapes(IIf(SellStop, shapeDownArrow, shapeNone),colorRed, 0,H, Offset=-10);

// EXPLORATION CODE STARTS HERE
backColor = IIf( Buy, colorGreen,colorRed);

Filter = Buy OR Sell;
SetOption("NoDefaultColumns", True );
AddTextColumn(Name(), "Scrip",1.2,colorWhite,backColor ,80);
AddColumn(DateTime(), "Date" ,formatDateTime,colorWhite,backColor ,120);
AddColumn(IIf( Buy, 66, 83 ), "Signal", formatChar,colorWhite,backColor ,50);
AddColumn(C,"Trade Price",1.2,colorWhite,backColor ,80);
AddColumn(Ref(C,-shiftStop),"Stop",1.2,colorWhite,backColor ,80);


// EXPLORATION CODE ENDS HERE
_SECTION_END();
 
Last edited:

findvikas

Well-Known Member
#3
Back testing Results

Common Parameters For All Tests:
Period: 1 Sep. 2008 - 19 Feb. 2010
Interval: Daily
Initial Capital: 10,000
MA Period: 21
Shift Stop: 3

Trade On Current Bar's Close price: Assuming trade is executed @ 3pm

Unitech



Reliance



Nifty Current Month Futures



DLF

 
Last edited:

findvikas

Well-Known Member
#4
Like no system is perfect, this is also at very initial stage. I am trying to keep it as simple as possible that anyone can trade even without looking at AFL or opening AmiBroker as well.

It also has Exploration Feature and the output comes like this...

 

findvikas

Well-Known Member
#9
I am not sure how many of you are interested but I have created an Expert Advisor for automated trading FX based on this strategy. I am running the tests on a demo account and let you know the performance.

I am not sure if the script is created properly as I am very new to MQL... any MetaTrader expert here to verify my script?
 

findvikas

Well-Known Member
#10
Not every stock MUST perform similar with any system and likewise I was able to identify these few stocks which performed way too good with this system.

I would be tracking these stocks for any daily triggers and see how they perform.

ABAN.NS
ADLABSFILM.NS
ANDHRABAN.NS
ANSALINFR.NS
AUROPHARM.NS
BAJAJHIND.NS
BALRAMCHI.NS
BHUSANSTL.NS
BOMDYEING.NS
CENTRALBK.NS
CHENNPETR.NS
CMC.NS
CUMMINSIN.NS
GUJALKALI.NS
HAVELLS.NS
HDIL.NS
HINDZINC.NS
INDUSINDB.NS
IVRPRIME.NS
JETAIRWAY.NS
JPHYDRO.NS
KESORAMIN.NS
LAXMIMACH.NS
MAHSEAMLE.NS
MPHASIS.NS
NATIONALU.NS
NDTV.NS
NUCLEUS.NS
ORCHIDCHE.NS
PATELENG.NS
PATNI.NS
PENINLAND.NS
REDINGTON.NS
RELCAPITA.NS
SHREECEM.NS
STAR.NS
STRTECH.NS
SUZLON.NS
TATAMOTOR.NS
TATASTEEL.NS
UNITECH.NS
WELGUJ.NS
WIPRO.NS



All of them gave above 100% return.. some of them gave 300%-500% while 1 stock gave whopping 800% return :)
 
Last edited:

Similar threads