Australian (ASX) Stock Market Forum

Developing a mechanical system from scratch

Can,

Have you been able to understand and convert the metastock code?

Weird uses a good style and his code is easy to follow.

"LE" = Long Entry

Substitute "Buy =" in AB

"ShE" = Short Entry

Substitute "Short =" in AB

From Doc's code:

"(2*Ref(Mov(V,13,E),-1))" converts to "(2*Ref(EMA(V,13),-1))"

"Ref(Mov(H-L,13,E),-1)" converts to "Ref(EMA(H-L,13),-1)"

It usually straightforward to convert most Metastock to AB or vice versa.

Ran some tests using weird and doc's code last night. Picked up a couple of illiquid stocks using the volume test of doc's. Doc made a comment related to the multiplier when he posted the code.

Let us know when you are ready Can and we can do some more work on this exercise. Hope your Internet conenction gets sorted out. Raise any questions that you may have along the way, as you can see there is always someone around who can help out.

Cheers.

I actually thought that the MS code was easier to understand than AB, just on first glance.

Anyway i haven't had a chance to do a thing on this. I've got my AB setup on my lappy at work thru a flask disk (not perimitted to install programs on work PCs), but Premium Data won't install on the flash disk...so no i've got a whole new range of issues to deal with, AB and no data...nothings ever simple is it?:banghead:

If someone can post some recent code efforts, i'll try and get some time to run some more tests tonite when i get home. I've got vacation days starting mid June that i'm dedicating to system development and learning, so if all else fails i may have to wait until then.

Cheers all, and thanks for the continued help and interest.:)
 
I've got my AB setup on my lappy at work thru a flask disk (not perimitted to install programs on work PCs), but Premium Data won't install on the flash disk...so no i've got a whole new range of issues to deal with, AB and no data...nothings ever simple is it?:banghead:

AB has an excellent data import wizard. If you can get some data into a CSV or Metastock format you can point the import wizard at those files and suck them into AB. Should get it onto your flash disk, no worries.
 
ok here is one with Moving Averages. Its note entirely mine, but I modified it quite a bit. U can play with the paramaters to change various nos.

Code:
p1=Param("EMA Period",15,1,200,1);
p2=Param("Smoothening Period",15,1,200,1);
p3=Param("Bollinger Period",5,3,25,1);
p4=Param("Bollinger Band Width",1,0.5,3,0.1);
p5=Param("Period for Buy",9,3,50,1);
p6=Param("Period for Sell",3,3,50,1);

X=EMA(C,p1);Y=EMA(X,p2);
D=X-Y;
BBB=BBandBot(D,p3,p4);
BBT=BBandTop(D,p3,p4);

Buy=Cross(D,BBT) AND (C>=MA(C,p5));
Sell=Cross(BBB,D) AND (C<=MA(C,p6));
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);

shape=Buy*shapeUpArrow+Sell*shapeDownArrow;
PlotShapes(shape,IIf(Buy,colorBrightGreen,colorRed),0,IIf(Buy,L,H));
 
theasxgorilla and Nick Radge

I was not trying to throw a monkey wrench into the works but was just explaining what I thought the definitions of a swing trade was in my mind at least. I see the advantages of holding a stock no longer than one day at a time but I also see that you can potentially miss some very nice moves in a stock over a several day period before it expirences another pull back.

To tell the truth I trade on the US makets and really have no idea what CFD's are or how they work. The point I was trying to make is that you are attempting to build a short term (swing) trading system. In the beginning of the thread I thought this was to allow someone with a day job who is unable to watch the market continually during the open hours of the market a viable way to trade stocks over the short term.

Disq
 
Disqplay,

Your comment seemed to be about how one might swing trade and in particular made reference to ,"at the first hint of failure of the stock to perform to it's potential is when your exit stratagey would kick in".

Most people would probably presume that you need a trailing stop as part of an exit strategy. One the other hand though, it's entirely viable with a short term system (not just any short term system, but one designed for the purpose) to buy on your entry trigger and sell; at a profit target, when a time based stop is hit, or when the initial stop is reached. If the system is super-short term and still trading on end-of-day signals it could be quite difficult and ultimately counter productive to have a trailing stop. Testing should tell this one way or another.

ASX.G
 
Apologies to all following this thread.

Stay tuned for some new developments from myself once i get some minor software issues resolved.

Thanks again to all contributors.

Cheers,
 
Look forward to having you fully functioning CanOz.

Need some help with coding in MS. My data contains warrants and options etc etc. Is there any way to limit the results of explorer in ms to stocks without having to add each to manually?

In Amibroker, I used to use something like (going from distant memory here, so the syntax might be wrong): strlen(name())==3. Does Metastock have an equivalent expression?
 
Tradesim does.

Place in english or Metastock the code and I'll give it a go.
If I cant get it Weird will.
Can then run it on Tradesim with monte carlo analysis, and all the bells and whistles.
 
G'day all.

This morning i started reading Howard Bandy's "Quantitative Trading Systems".

This was just released this year i believe. So far its very indepth and covering systems development in logical and more importantly, undetstandable steps. All, with AmiBroker:)

As far as the testing goes, i've tested Lesms code several times on my ASX data. Ron1n has tested it on ASX200. I tried to filter to this but the BT won't pick up anything, so i suspect its the way i have it setup....my data has warrants and options as well.

One thing i noticed about the system so far is that the MAXDD seemed high, to me anyway.

I can't post the report as i don't have MS word at home.:banghead:

I might recap where we are at today or tomorrow, following along the lines of Bandy's suggested path for those of you that are interested.

After that i will most likely pick this up a bit as i make my way through his book and while i'm on my holidays starting the 18th of June.

If someone else could post a few back tests of Lesms code? Has anyone tried an different exit yet?

Another question, do the code settings always override the backtest settings?

Cheers,
 
G'day all.

This morning i started reading Howard Bandy's "Quantitative Trading Systems".

This was just released this year i believe. So far its very indepth and covering systems development in logical and more importantly, undetstandable steps. All, with AmiBroker:)

As far as the testing goes, i've tested Lesms code several times on my ASX data. Ron1n has tested it on ASX200. I tried to filter to this but the BT won't pick up anything, so i suspect its the way i have it setup....my data has warrants and options as well.

One thing i noticed about the system so far is that the MAXDD seemed high, to me anyway.

I can't post the report as i don't have MS word at home.:banghead:

I might recap where we are at today or tomorrow, following along the lines of Bandy's suggested path for those of you that are interested.

After that i will most likely pick this up a bit as i make my way through his book and while i'm on my holidays starting the 18th of June.

If someone else could post a few back tests of Lesms code? Has anyone tried an different exit yet?

Another question, do the code settings always override the backtest settings?

Cheers,

Can,

Wats a high maxDD to you?
>30% ??

Depends on the profits and trading timeframe i guess.

Also, you dont have MS word at home?
Are you serious??
Thats just weird.... :banghead:
 
Can,

Wats a high maxDD to you?
>30% ??

Depends on the profits and trading timeframe i guess.

Also, you dont have MS word at home?
Are you serious??
Thats just weird.... :banghead:

I don't have MS Office at home at the moment, its a new PC and it was suggested to me not use a lic. copy. In the meantime no copy has been presented to me for use as promised...alas i will be buying a licensed copy very soon if i can find a dual language or english version...Nothing is simple here Nizar.

Anyway...i've been reading all day...now i need to practice writing some filters and creating some watchlists.....This book is great!

Cheers,
 
Hi DoctorJ,

There are a few methods I know of to create a watchlist/favourites with only the required symbols for Metastock.

As Tech/A mentioned, it is very easy to do this with Tradesim, and symbols (example > 3 characters) can be filtered out with a line of code, and even produce a watchlist/favourites based on this (that is only symbols <= 3 characters).

Most data providers provide methods as well, such as Premium Data, and I also remember mucking around with a method to do so using Almax as well to create a watchlist from a text file. So if you can ween out the symbols you don't wish to include from a text file, you could import this text file to create a watchlist with only the symbols you require.

Also most data providers provide set watchlists based on ASX constituent index groups, which "may" exclude the symbols, such as warrants and options, you don't wish to include. May be worth sending them a quick email.

Also there are some other utilities available which may help, such as Jose's URSC kit, and also with a new utility from Jim Berg,

http://www.sharetradingeducation.co...TradingTools/BergListCreatorforMetastock.aspx
 
Also, as I'm not sure what there is available concerning free dll's or coding that can provide additional symbol filtering for MS, a good place to ask would be,

http://forum.equis.com/forums/default.aspx

The MS programming heavies frequent that site, so can provide additional tips and information.
 
Wouldn't the liquidity filter take care of that anyway wierd? I mean it would be unlikely wouldn't it to have such high liquidity in an option or warrant when the conditions of the system are met?

Doc maybe your query was in general and not related to this particular system?

In any case im going to try and figure out how to limit the symbols length in AB as an exercise.:)

Cheers,
 
/* Clean up database*/

/*there are the string functions to help with these
run the explore, save all to a watchlist then in Assignment Organizer
delete them

example*/

Filter= StrRight(Name(),3)==".AX" OR StrLen(Name())>4;
AddTextColumn(Name(),"name");

I use the above code to clean out any symbols that are longer than than 4 letters.

I use two ASX databases.

Adjusted EOD data I get from Premium Data which assigns the data to the various watchlists automatically at the end of day when updating.

The second database is unadjusted data that includes warrants and options and is intra day. I use the above code to clean it up. The data originally was sourced from Yahoo, and the code was designed to get rid of the .AX extension.

I have just ordered the Quantitive Trading Systems book myself and am interested in your comments. I've had AB for some years now, however, my programming skills are still pretty rough.

Anyway, came across this thread by accident and am finding it an interesting read. Keep up the good work guys.

Cheers
IJW
 
Been chugging along with this medium term mechanical system idea and shorter term trend exits keep coming up as suboptimal compared to wider exits.

Longer term ema's (circa 120 days on my selected universe of stocks) seem to be the most profitable.

This applies to straight mechanical systems. Nothing is coming even close to my swing trades and more discretionary medium term trend trades in expectancy X opportunity. (discretionary in this case means useing well defined t/a, but differing techniques as the situation demands and not whims, or gut feels.... trendlines, supp, res, etc)

Note:
My backtesting skills are rudimentary
Tested on US share data
Trading ideas kept purposefully simple for reasons of robustness

So far I'm thinking if you want to go mechanical, go longer term. (Bearing out the techtrader experiment)

Shorter term systems work, but I think they have to be a bit less mechanical lest they underperform longer systems.

Anyone else coming up anything different?
 
Top