Australian (ASX) Stock Market Forum

Medium to Long term system development

Joined
11 May 2005
Posts
573
Reactions
3
Re: Developing a System to Trade Live

Moderator's Note: This thread originally started in another general thread on systems development so it may be a bit jumbled at first for those unfamiliar with it. The idea here is to develop a medium to longterm system. Click here for a thread on a short term system.


mit said:
Another thing to look at is stocks reaching a 52 week high. Once they pass this the skys the limit as there is little overhead resistance. However, the 52 week high itself is a resitance and stocks hitting this may subsequently dive. We would need some confirmation such as the stock has kept going up once it has hit the 52 week high or we can look at a 1-2-3 formation as this increases the probability of success and gives us an initial hard stop at the 2 point.

MIT

Thanks for the info,

Buy high and sell higher is the key concept in techtrader. I don't mind going down that path as opposed to a reversal system as we were aiming for a shorter term system (weren't we?) and generally a better win/loss ratio is needed.

Does anyone else mind?

The Darvus/1-2-3 entry is one of my favorites. I've always thought the 52-week high would make an interesting variable. Has anyone tested this?
 
Re: Developing a System to Trade Live

loakglen said:
Thanks for the info,

Buy high and sell higher is the key concept in techtrader. I don't mind going down that path as opposed to a reversal system as we were aiming for a shorter term system (weren't we?) and generally a better win/loss ratio is needed.

Does anyone else mind?

The Darvus/1-2-3 entry is one of my favorites. I've always thought the 52-week high would make an interesting variable. Has anyone tested this?

Loakglen,

I thought we were going longer term for the beginners? Personally I have a long term system and would like to round out my systems with a short term system (I even have an idea for a go-short system). Maybe do a long term system first?

MIT.
 
Re: Developing a System to Trade Live

Well the following is a basic system where you buy the 52 week high. It is profitable but the drawdown is unacceptable. But it is barebones to start fleshing out a system. It simply buys on open where yesterday was at a 52 week high and only selects stocks that have an average daily turnover of $500k or more

MIT

/********************************************************
Aussie Stock Forums System
*********************************************************/

// Setup Options
SetOption("InitialEquity", 10000);
SetOption("FuturesMode", False);
// Parameters
TrailATR = 6.5;
Period = 14;
MaxPosition = 15;
// Set the trailing stop also used to set the position size
Trail = ATR(Period) * TrailATR;

Buy = Ref(H,-1) == Ref(HHV(H,250),-1)
AND EMA(V*C, period) > 500000;

// Yesterday was 52 week high and liquidity > $0.5m
BuyPrice = O; // Buy todays open

Sell = 0; // We don't need an explicit stop as we use trailing stop


// Set up trailing stop
ApplyStop( stopTypeTrailing, stopModePoint,Trail, 0, True );

// Set the position size so we only lose 2%
PositionSize= 2*BuyPrice/Trail;
// If the position is larger than 25% of our money then
// ask for a smaller amount
PositionSize = IIf(PositionSize > MaxPosition, -MaxPosition, -PositionSize );
/**********************************************************************************************/
 
Re: Developing a System to Trade Live

The trade stats are as below. The drawdown at over 80% is too high. Also the 72% annual profit is suspect when I test the sensitivity of the parameters. I reduced the trail multiplier from 6.5 to 6 and the profit halved.
Sorry about the untidy format. I'll have to think of a way to get it tidier.

MIT

All trades
Initial capital 10000
Ending capital 67918.76
Net Profit 57918.76
Net Profit % 579.19%
Exposure % 65.86%
Net Risk Adjusted Return % 879.37%
Annual Return % 72.10%
Risk Adjusted Return % 109.46%


All trades 531
Avg. Profit/Loss 109.07
Avg. Profit/Loss % 7.37%
Avg. Bars Held 107.95


Winners 245 (46.14 %)
Total Profit 122567.66
Avg. Profit 500.28
Avg. Profit % 28.98%
Avg. Bars Held 165.38
Max. Consecutive 32
Largest win 5362.52
# bars in largest win 148


Losers 286 (53.86 %)
Total Loss -64648.9
Avg. Loss -226.05
Avg. Loss % -11.14%
Avg. Bars Held 58.74
Max. Consecutive 15
Largest loss -2092
# bars in largest loss 65


Max. trade drawdown -2548.8
Max. trade % drawdown -74.65%
Max. system drawdown -44040.84
Max. system % drawdown -81.39%
Recovery Factor 1.32
CAR/MaxDD 0.89
RAR/MaxDD 1.34
Profit Factor 1.9
Payoff Ratio 2.21
Standard Error 13743.75
Risk-Reward Ratio 1.19
Ulcer Index 38.21
Ulcer Performance Index 1.75
Sharpe Ratio of trades 0.23
K-Ratio 0.04
 
Re: Developing a System to Trade Live

I added the trend confirmation using the Guppy MMA as follows:

AND BarsSince( Cross(MA(C,50), MA(C,45) ) ) > period
AND BarsSince( Cross(MA(C,45), MA(C,40) ) ) > period
AND BarsSince( Cross(MA(C,40), MA(C,35) ) ) > period
AND BarsSince( Cross(MA(C,35), MA(C,30) ) ) > period
AND BarsSince( Cross(MA(C,35), MA(C,5) ) ) > period
AND MA(C,50) < MA(C,45)
AND MA(C,45) < MA(C,40)
AND MA(C,40) < MA(C,35)
AND MA(C,35) < MA(C,30)
AND MA(C,35) < MA(C,5)



and the profit increased to 98% and the drawdown reduced to 65%. Better but the drawdown is still larger than we would want. The profit seems incredible mainly because the market between March-2003 and March-2005. I'll do a run up until March-2003 and we should see the difference.

Time to feed to dogs

MIT
 
Re: Developing a System to Trade Live

Mit,

What settings are you using for your backtests?

I ran your exact formula (without the GMMA additions) as a backtest in AmiBroker and couldn't get anything like the results you got. Best I could get from 1/3/2003 to 31/3/2005 with buy on today's open and no brokerage was about 42% pa. With $20 brokerage per trade and buy on average price one day delayed I could only get about 28% pa. And the maximum system draw-down in the latter case was only -8.35%.

That was all using the ASX200 list as the stock universe, although another test using all stocks gave about the same result.

Cheers,
GP
 
Re: Developing a System to Trade Live

GP,

Thanks, I'll have a look. I am using $20 a side as well. It looks to me as though it is trying to run in futures mode. I have deliberately have tried not to put forward a perfect system so the beginners can see how much you have to do to check it out.

MIT
 
Re: Developing a System to Trade Live

GP,

That's interesting. I had futures mode set to off in the code. I had it set to off in settings but because I had Margin Requirement set to "1" in the settings Amibroker ignored the other settings and put it into Futures mode. (I usually test leveraged systems).

Using your period I get 24% annual profit and 6.5% drawdown. That's with the GMMA included and my asx200 could be out of date so it is pretty close to your result.

Michael
 
Re: Developing a System to Trade Live

mit said:
Loakglen,

I thought we were going longer term for the beginners? Personally I have a long term system and would like to round out my systems with a short term system (I even have an idea for a go-short system). Maybe do a long term system first?

MIT.

I thought we were going for a short term system too as Techtrader is clearly there for those who want a tested longterm system.
 
Re: Developing a System to Trade Live

RichKid said:
I thought we were going for a short term system too as Techtrader is clearly there for those who want a tested longterm system.

Well I never wanted short. Just shorter than Techtrader. Medium being my preference. I like what MIT has come up with so far anyway; as a bare bones.
:)
 
Re: Developing a System to Trade Live

loakglen said:
Well I never wanted short. Just shorter than Techtrader. Medium being my preference. I like what MIT has come up with so far anyway; as a bare bones.
:)

So would we define this method we are creating as one involving trading over weeks and months (as opposed to days)? I'm new to this so please excuse the need for detail. I assume techtrader is a longterm system in the sense of it looking at multi-year periods.
 
Continued from the other system development thread. To continue developing a medium/long term systems.

MIT
 
Re: Short/Long term system development

Story so far. The main idea was to buy on open shares that reach a 52 week high. To make sure that the stock is in an upward trend over a medium term we make sure that the long term set of EMAs of GMMA have not touched or crossed for some time and are in the appropriate order.

Exit for now is from a trailing stop. Brokerage is as per Commsec 19.95 upto 10k, 29.95 up to 20k and 0.12% after this.

We only risk 2% on each trade. The position size is then set that if we hit the trailing stop we will lose 2%. But if the size of the position is greater than 15% of our total capital we limit it to 15%


/********************************************************
Aussie Stock Forums System
*********************************************************/

// Setup Options
SetOption("InitialEquity", 10000);
SetOption("FuturesMode", False);
// Parameters
TrailATR = 6.5;
Period = 40;
MaxPosition = 15;
// Set the trailing stop also used to set the position size

Trail = ATR(14) * TrailATR;

// Yesterday was 52 week high and liquidity > $0.5m

Buy = Ref(H,-1) >= Ref(HHV(H,250),-1)
AND EMA(V*C, period) > 500000
AND BarsSince( Cross(MA(C,50), MA(C,45) ) ) > period
AND BarsSince( Cross(MA(C,45), MA(C,40) ) ) > period
AND BarsSince( Cross(MA(C,40), MA(C,35) ) ) > period
AND BarsSince( Cross(MA(C,35), MA(C,30) ) ) > period
AND BarsSince( Cross(MA(C,35), MA(C,5) ) ) > period
AND MA(C,50) < MA(C,45)
AND MA(C,45) < MA(C,40)
AND MA(C,40) < MA(C,35)
AND MA(C,35) < MA(C,30)
AND MA(C,35) < MA(C,5)
;


BuyPrice = O; // Buy todays open

BarsSinceBuy = BarsSince(Buy);

Sell = 0;

// Set up trailing stop
ApplyStop( stopTypeTrailing, stopModePoint,Trail, 0, True );

// Set the position size so we only lose 2%
PositionSize= 2*BuyPrice/Trail;
// If the position is larger than 15% of our money then
// ask for a smaller amount
PositionSize = IIf(PositionSize > MaxPosition, -MaxPosition, -PositionSize );
/**********************************************************************************************/
 
Re: Short/Long term system development

Testing for the period 1-Mar-1999 until today returned 17% per annum on average (MDD 26%). Which is better than the market.
However, there would be some survivorship bias in the results as we are using the current asx200.

There was a discussion on another thread about bang for buck. One way to measure this is the equation ATR()/C. A higher value means that a share is more volatile than other shares.

On any day if you have more shares than you have money, Amibroker by default simply pick's shares in alphabetical order.

You can override this and by including the line

positionscore = ATR()/C

tells Amibroker to buy shares in order of bang for buck. I added and the difference was SFA. Which surprised me as I expected a difference one way or the other. It could be that the GMMA filter forces a lower volatility.
 
Re: Short/Long term system development

Can you guys test a portfolio exit for me based on the XJO?
I'm on to TJ (Amibroker Creator) about it but still no reply on how to fix my setforeign function.
I'm going to do up the index so I can get around it that way :banghead:

Here it is:

SetForeign("xao",True,False);
Sell=Cross(L,EMA(C,180));
RestorePriceArrays(False);

It should fit in nicely with your trailing stop.

Have a play and see what you come up with-

Thanks.
 
Re: Short/Long term system development

loakglen said:
Can you guys test a portfolio exit for me based on the XJO?
I'm on to TJ (Amibroker Creator) about it but still no reply on how to fix my setforeign function.
I'm going to do up the index so I can get around it that way :banghead:

Here it is:

SetForeign("xao",True,False);
Sell=Cross(L,EMA(C,180));
RestorePriceArrays(False);

It should fit in nicely with your trailing stop.

Have a play and see what you come up with-

Thanks.

Don't worry about it- I fixed it myself! I'm smarter than I thought- I can fix a simple data prolem :eek:

I'm coming up with some pretty good stuff with that idea. There's heaps of stuff, most of which ive never heard of on the Amibroker site even just to get ideas.
 
loakgen,

There is also some interesting things you can do in Amibroker with your equity curve. Using the XJO is good but I have noticed that in a short term my equity goes north when the XJO goes south and visa versa. I think that this is because the few largest stocks tend to drive the market or a particular sector drives the market.

Another one if to do an equity based filter do the following. Run your system in backtest.

Add the following line:

AddToComposite( Equity(), "~RawEquity", "X" );

Do a scan and a new ticker "~RawEquity" should appear. It will be in group 255. Now comment out the line above

and you can use

eqC = GetForeign("~RawEquity","C");

and do pretty much the same thing you are doing with XJO.

I have done some work on this system with good results, I'll post when I get a minute.

MIT
 
Re: Short/Long term system development

loakglen said:
Don't worry about it- I fixed it myself! I'm smarter than I thought- I can fix a simple data prolem :eek:

I'm coming up with some pretty good stuff with that idea. There's heaps of stuff, most of which ive never heard of on the Amibroker site even just to get ideas.

The last six months with Amibroker have been pretty exciting. Now that you can get very low level with the backtester we can try things that no other system can do (Other than writing a backtester from scratch). I currently find it hard to get my head around some of it. but to be able to test ...

. pyramiding into and out of a position. (Some systems can simulate it with difficulty)
. Test position size based on portfolio size (A person with $10k may be willing to risk 5% but someone with $200k may only want to risk 1%).
. Or if the last buy signal was unsuccessful then double/halve the bet on the current signal

I think that there could be some amazingly profitable techniques out there to be discovered beyond what people have been able to do over the last 10 years or so.

MIT
 
Any further headway on this?

Is there a sticking point?

Can I help?
 
Sticking point is time at the moment. I have done some changes and am getting good results of around around 28%. Just need time to write it up. I have some work deadlines I need to meet (Alas I will be happy when I can trade full time). Probably write up the latest tomorrow.

MIT
 
Top