Australian (ASX) Stock Market Forum

My Trading Plan/System (Beginner)

Good Luck :)

Offtopic: Is it true that if i am ages under 21 years i can start an IB account with just 3,000 USD? This is good news!

Do they enforce the 100 trade rule?

Where did you find this information?
Thanks!

Yeah it's true. It's in the required minimums section.
 
Well I've finished my system after working on it for 24 hours straight! Here it is:

Code:
_SECTION_BEGIN("VSA");

/*Variables*/
/***********/

Cap = SetOption("InitialEquity", Param("What is your starting capital?", 7500, 0, 1000000)); 								/*Your starting capital*/
percap = Param("What is the largest size of each trade, in terms of % of equity?", Optimize("% of equity",25, 1,100,5), 1, 100, 1); /*The largest possible size of each trade in terms of % equity*/
risk= Param("What % of your capital are you willing to risk per trade?", 1, 0, 100); 											/*The % of capital that is going to be risked per trade*/
W= Param("Number of bars to compare lowest close (for Covering)", 5, 0, 100); 													/*The number of previous bars today's close will be compared to*/
X= Param("Number of bars to compare highest close (for Selling)", 5, 0, 100); 													/*The number of previous bars today's close will be compared to*/
Y= Param("Trailing stop %", Optimize("Trailing stop %",3,0.1,10,0.1),0.1,10,0.1);											 	/*The percentage to be used for the trailing stop. Can be optimized.*/
Z= Param("Number of bars to compare size of spread", 15, 0, 100); 																/*The number of previous bars today's spread will be compared to*/

spread= H-L; 				/*Size of the spread*/
mid= L + spread/2; 		/*The midpoint of a bar*/
avol= MA(Volume,10); 	/*Formula for Average Volume*/
sl_short=1+Y/100; 		/*Stop loss level for going Short*/
sl_long=1-Y/100; 			/*Stop loss level for going Long*/





/*Going Long*/
/************/
SetTradeDelays(1,1,1,1);

/*Buy Condition: Three consecutive up-thrust days with successively increasing volume*/
Buy = Ref(C,-2)<Ref(C,-1) AND Ref(C,-1)<C AND Ref(C,-2)<C AND Ref(V,-2)<Ref(V,-1) AND Ref(V,-1)<V AND Ref(V,-2)<V;
BuyPrice = Open;

/*Sell Condition #1: Three days where the close is sideways (+/- 5% of each other) and volume is successively decling but larger than average for the first two days*/
/*Sell =  (Ref(C,-2)<1.025*Ref(C,-1) AND Ref(C,-2)>0.975*Ref(C,-1)) AND (Ref(C,-2)<1.025*C AND Ref(C,-2)>0.975*C) AND (Ref(C,-1)<1.025*C AND Ref(C,-1)>0.975*C);*/

/*Sell Condition #2: Sell on the bar with the smallest spread for the past 15 days, above average volume and a close towards the high with the bar in an uptrend.*/
Sell = spread<=LLV(spread,Z) AND V>avol AND C>mid AND C>=HHV(C,X);
SellPrice = Open;

/*Going Short*/
/*************/
/*Short Condition: Three consecutive down-thrust days with successively increasing volume*/
Short = Ref(C,-2)>Ref(C,-1) AND Ref(C,-1)>C AND Ref(C,-2)>C AND Ref(V,-2)<Ref(V,-1) AND Ref(V,-1)<V AND Ref(V,-2)<V;
ShortPrice = Open;

/*Cover Condition: Cover on bar with lowest close for X period, above average volume, small spread and with a close towards the low*/
Cover = spread<=LLV(spread, Z) AND V>avol AND C<mid AND C<=LLV(C,X);
CoverPrice = Open;





/*Applying a trailing stop*/
/*****************************************/
SetOption("AllowSameBarExit", 1);
SetOption("ActivateStopsImmediately",1);

trailARRAY_short = Null; 														//Holds the different prices that the trailing stop has been at (SHORT)
trailstop_short = 0; 															//Trailing stop price (SHORT)


//This loop does the following tasks:
//	1. Checks to see if we're shorting on the particular day, otherwise, removes the short signal.
//			a. If a position is entered, the entry point is the Open of the NEXT DAY.
//	2. Applies the trailing stop as a percentage of the High.
//	3. Checks to see if the trailing stop has been broken by the High. If it has, the position is Covered and the trailing stop is reset.
//	4. If the High hasn't penetrated the stop, then the trailing stop moves lower.
for( i = 1; i < BarCount; i++ )
{
   if( trailstop_short == 0 AND Short[ i ] ) 								//if there is a buy signal with no trailing stop moving under it, then buy on the next day's open
   { 
		SetTradeDelays(1,1,1,1);
		ShortPrice = Open;
      	trailstop_short = High[ i ] * sl_short;
   }
   else Short[ i ] = 0; 														//remove excess short signals
   if( trailstop_short > 0 AND High[ i ] > trailstop_short )				//if the trailing stop is triggered, exit position immediately (intraday)
   {
      	Cover[ i ] = 1;
		SetTradeDelays(1,1,1,0);
      	CoverPrice[ i ] = trailstop_short;		
      	trailstop_short = 0;
   }

   if( trailstop_short > 0 AND High[ i ] < trailstop_short )				//if the trailing stop isn't triggered, move it closer
   {   
      	trailstop_short = Min(High[ i ] * sl_short, trailstop_short);
      	trailARRAY_short[ i ] = trailstop_short;
		
   }
}

	
trailARRAY_long = Null; 														//An array that holds the different prices that the trailing stop has been at (LONG)
trailstop_long = 0; 																//Trailing stop price (LONG)

//This loop does the following tasks:
//	1. Checks to see if we're buying on the particular day, otherwise, removes the buy signal.
//			a. If a position is entered, the entry point is the Open of the NEXT DAY.
//	2. Applies the trailing stop as a percentage of the Low.
//	3. Checks to see if the trailing stop has been broken by the Low. If it has, the position is Sold and the trailing stop is reset.
//	4. If the Low hasn't penetrated the stop, then the trailing stop moves higher.
for( i = 1; i < BarCount; i++ )
{
	if( trailstop_long == 0 AND Buy[ i ])										//if there is a buy signal with no trailing stop moving under it, then buy on the next day's open
	{
		SetTradeDelays(1,1,1,1);
		BuyPrice = Open;
		trailstop_long = Low[ i ] * sl_long;
	}
	else Buy[ i ] = 0; 															//remove excess buy signals
	if( trailstop_long > 0 AND Low [ i ] < trailstop_long )				//if the trailing stop is triggered, exit position immediately (intraday)
	{
		Sell[ i ] = 1;
		SetTradeDelays(1,0,1,1);
		SellPrice[ i ] = trailstop_long;
		trailstop_long = 0;
	}

	if (trailstop_long >0 AND Low[ i ] > trailstop_long )					//if the trailing stop isn't triggered, move it closer
	{
		trailstop_long = Max(Low[ i ] * sl_long, trailstop_long);
		trailARRAY_long[ i ] = trailstop_long;		
	}
}

//This sub-section plots the price and the trailing stops.
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();
Plot( trailARRAY_short,"SHORT - trailing", colorIndigo, styleThick );
Plot( trailARRAY_long, "LONG - trailing", colorBlue, styleThick);





/*Fixed Fractional Position Sizing*/
/**********************************/

SetCustomBacktestProc("");  													//tells amibroker that we're running our own custom backtest procedure

if (Status("action") == actionPortfolio)  									//runs the code in the second part of the backtest procedure
{
	bo = GetBacktesterObject();
	bo.PreProcess();
	for (i = 0; i<BarCount; i++) 												//cycles through all the bars
	{
		for (sig = bo.getfirstsignal(i); sig; sig = bo.getnextsignal(i)) //cycles through all the signals for the current bar
		{

			
			if (sig.IsEntry())  													//if the bar involves an entry... this is used to catch all short entries. A nested if-statement is used to catch long entries.
			{
				psize=sig.PosSize;
				
				sp = Foreign(sig.Symbol, "H");									//imports the High array for the current symbol
				spi = sp[i] * sl_short;											//uses the i-th High value to calculate the trailstop value, just like trailstop_short
				bp = Foreign(sig.Symbol, "O");									//imports the Open array for the current symbol
				bpi = bp[i];														//sets the i-th Open value

				e=bo.Equity();													//the current equity of the portfolio
				Check = (percap/100)*e;											//converts the maximum % of equity per trade into maximum $ per trade
				r=(risk/100)*e;													//maximum risk per trade
				psize=(r*bpi)/abs(bpi-spi);										//calculates the fixed fractional position size for each short entry
				if (sig.IsLong())													//if the bar involves a long entry...
				{
					sp = Foreign(sig.Symbol, "L");								//imports the Low array for the current symbol
					spi = sp[i] * sl_long;										//uses the i-th Low value to calculate the trailstop value, just like trailstop_long

					psize=(r*bpi)/abs(bpi-spi);									//sets the new position size, according to the new trailstop (ONLY FOR LONG TRADES)
				}
				if (psize>Check)													//checks if the position size calculated is greater than the maximum $ per trade. If so, position becomes the max possible $ per trade
				{
					psize=Check;
				}

				sig.PosSize=psize;
			}		
		}
		bo.ProcessTradeSignals(i);
	}
	bo.PostProcess();
}

How does the system work?
=======================

  • Just a trend following system
  • Buys after three days of successively higher closes and volume. Short is vice versa.
  • Sells on bars with small spread, above average volume and with a close towards the high. Cover is similar except with close towards the low.
  • Positions are closed by the trailing stop intraday
  • Uses a trailing stop of 3% (adjustable)
  • Capital is divided into parcels of max. 25% of original equity. Position sizes are then worked out using the fixed fractional method.
 

Attachments

  • VSA - Narrow Spreads & High Volume.afl
    8.7 KB · Views: 18
What does the system look like?
========================

sys.png

The squiggly lines are the trailing stops. The blue line is the trailing stop for a long position and the pink line is for shorts.
The trailing stop is a percentage of the previous bar's low (if long) or high (if short), however this can be changed to some other variable within the AFL script. The % can be adjusted using the "Parameter" button in amibroker->auto analysis.

What are the results like?
=====================


I'm pretty pleased with the results. Its funny that they improved because of the amount of time I spent working on the trailing stop and position sizing rather than buy/short triggers.
The system traded the ASX top 200, using a trailing stop of 3% and no static stop loss.

sysresults.jpg


Given that the XAO has been trending downwards since late 2007, losses were expected whilst going long between 01/01/2008-23/02/2009 and 01/09/2088-23/02/2009. I was surprised by the gain from 01/01/2009-23/02/2009 with all the sideways movement on the XAO.
I'm a bit skeptical about the going short result from 01/01/2009-23/02/2009. The Win% is extremely high and so is the Risk/Reward ratio. I'm assuming this is just an anomaly.
All in all, I'm quite pleased with the results, especially the avg. profit per week :)


What's next?
============


Well, I'd like to see how this system would go in other markets, in particular the US markets, HOWEVER, I don't have any data for them.
If anyone does have access to that data it'd be much appreciated if you could post the results up.
The next system will be one for forex, probably a breakout or gapping system. Maybe this will be a bit more challenging since there's no volume. I'll post it up when I finish it for any other newbies that want an example system.
 
Good that its working out for you.

Playing devils advocate here...

In your back testing, I hope you have you taken the following into account -

1. commission and rates?

2. stocks that are (effectively) delisted. (I literally copied and pasted your script, and BNB came back as a search result - does that matter?)

Item 2 is easy to overcome... just mod your watch list.

Something which looks good may not be so if you are paying $15, $20 or $30 (ignoring IB) each time that you buy or sell.

Tim
 
Good work saiter.
Are you sure BLR is top200 though?
Last time I traded it (maybe 2 years ago) it was a spec.
 
Good that its working out for you.

Playing devils advocate here...

In your back testing, I hope you have you taken the following into account -

1. commission and rates?

2. stocks that are (effectively) delisted. (I literally copied and pasted your script, and BNB came back as a search result - does that matter?)

Item 2 is easy to overcome... just mod your watch list.

Something which looks good may not be so if you are paying $15, $20 or $30 (ignoring IB) each time that you buy or sell.

Tim

Good work saiter.
Are you sure BLR is top200 though?
Last time I traded it (maybe 2 years ago) it was a spec.


I've taken commissions into account ($12 per trade w/ 0.08% commission).
I'm using the ASX amibroker database, so I assumed that the watchlist it created was top 200. I'll double check it.

EDIT: Thanks for letting me know about this. I've downloaded the ASX200 list and I'll post the proper results up
 
My comment is that your shorting ystem has some potential but your long method needs some work.
 
Saiter, what have you concluded so far from your results?

  • The trend really is your friend
  • It's possible to make $150 per week with my starting capital


You mean long in a down trend?

Given his parameters no doubt!

Tighter trailing stops result in losses for long positions. Larger trailing stops result in only minor gains. The only other thing I could change would be my risk, but I'm not sure if that'd be such a good idea considering my small capital.
 
Hi saiter, have you considered lowering youre timeframes a bit to account for market volatility and generate more trade signals?

3 days of rising volume and the move might already be gone by the time your system generates a signal.
 
Saiter, have you tried the system but with ommitting the volume data?
ie. only consider price action.

What are you observations?
 
Hi saiter, have you considered lowering youre timeframes a bit to account for market volatility and generate more trade signals?

3 days of rising volume and the move might already be gone by the time your system generates a signal.

Saiter, have you tried the system but with ommitting the volume data?
ie. only consider price action.

What are you observations?

I'll be testing these later tonight and I'll be using different VSA-based entry/exit triggers. I should say though that the only time this became profitable was when the trailing stops & position sizing was implemented, so I'm not sure if changes to the triggers would make that much of a difference.
 
Well it looks like my trading plan/system isn't going to work.

Unfortunately, as I'm under the age of 21, I'm restricted to a cash account at Interactive Brokers, meaning that I cannot short any stocks. Furthermore, I'm unable to trade FOREX as I can't switch to a margin account (underage).

Does anyone know of any other brokers that offer both FOREX and Australian stocks for a low comission?

Thanks.
 
Well it looks like my trading plan/system isn't going to work.

Unfortunately, as I'm under the age of 21, I'm restricted to a cash account at Interactive Brokers, meaning that I cannot short any stocks. Furthermore, I'm unable to trade FOREX as I can't switch to a margin account (underage).

Does anyone know of any other brokers that offer both FOREX and Australian stocks for a low comission?

Thanks.

You would find it hard to short with IB anyway. They haven't had much on their list recently.

Looks like you need a bucket shop. They are always willing to let you trade.
 
You would find it hard to short with IB anyway. They haven't had much on their list recently.

Looks like you need a bucket shop. They are always willing to let you trade.

The only one I know of is commsec and that'd cost $20+$40 for a round trip to short. The other option is belldirect with a $30 round trip for going long ONLY. I can't go long atm and come out positive.
 
The only one I know of is commsec and that'd cost $20+$40 for a round trip to short. The other option is belldirect with a $30 round trip for going long ONLY. I can't go long atm and come out positive.

No No No. Try one of the CFDs like CMC you can even short the fins
 
Top