- Joined
- 13 June 2007
- Posts
- 838
- Reactions
- 136
Hi All,
I'm a newbie here and just bought Amibroker V5.80 charting software with Premium data EOD ASX.
Interested in learning how to code/design a trading system for the ASX shares to start with. I realised there is no in-built system in AB to learn and practice with.
Problem is that I have no programming background and AFL seems a little bit daunting for a newbie.
What would be the best approach for people new to system trading?
Any good books to read?
Have read Nick Radge's Unholy Grail and been looking for TechTrader's trading system without any luck.
Contemplating to join The Chartist but read somewhere that a decent trading system has to fit the trader's own personality.
Buying "off the shelf" system may or may not work for me.
Any advice much appreciated.
Thanks.
Iro
Greetings --
Download the free pdf version of my "Introduction to AmiBroker" here:
http://www.introductiontoamibroker.com/book.html
Work through the exercises in Chapter 3 -- 30 Minutes to Useful Results.
Best,
Howard
Hi Amimad,Hi Ironik,
As for Nick Radge his membership entitlles you to a lot of useful educational material not just his trading setups. You can trial his site or just join for a month or so at about $90 a month I think and gain loads of useful trading/charting info(if you need it).
Also once you get a trading strategy in place Nick or I'm sure there are any loads of other top quality AFL programers on this site that you can pay to code your strategy so all you have to do is push a button on amibroker once a day to get ya trades.
But if your like me you probably want to do it yourself(the hard way!) so let the journey begin..
Don't forget the AFL wizard that helps to convert your rules in plain English into afl code (haven't used it myself yet).
I found Howard's free book "introduction to amibroker" indispensable I keep re reading chapter 8 and still haven't got it all..
Cheers
Either save your exploration as project file (.apx extension) after setting Apply to: to Filter -> including your watchlist (side note, project files save all backtest and toolbar settings plus your entire AFL code)
or/and
In your exploration block you add InWatchlist( wlnum )
Ie.
Code:wlnum = 0; // your watchlist number if ( Status("actionex") == actionExplore and InWatchlist( wlnum ) ) { // your exploration code here Filter = .... }
AB = new ActiveXObject( "Broker.Application" ); // creates AmiBroker object
AB.LoadDatabase( "C:\\Program Files\\NorgateDB\\" ); // insert path to norgate database
try
{
NewA = AB.AnalysisDocs.Open( "C:\\analysis1.apx" ); // opens previously saved analysis project file
// NewA represents the instance of New Analysis document/window
if ( NewA )
{
NewA.Run( 1 ); // start exploration
while ( NewA.IsBusy ) WScript.Sleep( 500 ); // check IsBusy every 0.5 second
//NewA.Export( "test.html" ); // export result list to HTML file
WScript.echo( "Exploration Completed" );
NewA.Close(); // close new Analysis
}
}
catch ( err )
{
WScript.echo( "Exception: " + err.message ); // display error that may occur
}
You are asking the restaurant owner whether the food is any good.Hi Howard,
Thanks for the link.
Is the following book a good start for people like me? Will newbies benefit from this book? I'm struggling to find materials regarding structured method to trading system design. I see that you have a few books on your website, but not sure which one would suit me at this early stage of my journey (as a newbie).
Quantiative Technical Analysis,
An Integrated Approach to Trading System Development and Trading Management
by Dr. Howard Bandy
The book discusses trading system development and trading management.
Thanks,
Iro
I don't appreciate the aggression, which is why you're on my list of Amibroker issues.
BTW, this one goes on the list of the most ridiculous sentences of year 2014.
Do you want to explain your statement? Astonish us with a shock revelation that you're actually Tomasz?
You didn't say that you run two DBs.
You can save the BuyPrice of your scans to Persistent variables using i.e.
StaticvarSet( "NorgateDB_BuyPrice_" + Name(), Lastvalue( BuyPrice ), storage = True );
in the exploration code you use in your Norgate DB.
Then after closing AB and reopening on next day you can access them in IAB DB using mybuyprice = StaticVarGet( "NorgateDB_BuyPrice_" + GetFnData( "Alias" ) );
In Alias field of symbol's Information window of IAB DB you enter the name of the Norgate DB's according symbol in case it is different from IAB symbology. If symbol names are the same ones then use mybuyprice = StaticVarGet( "NorgateDB_BuyPrice_" + Name() );
As for running first exploration in Norgate DB only use example jscript to load that DB and execute project file there.
Code:AB = new ActiveXObject( "Broker.Application" ); // creates AmiBroker object AB.LoadDatabase( "C:\\Program Files\\NorgateDB\\" ); // insert path to norgate database try { NewA = AB.AnalysisDocs.Open( "C:\\analysis1.apx" ); // opens previously saved analysis project file // NewA represents the instance of New Analysis document/window if ( NewA ) { NewA.Run( 1 ); // start exploration while ( NewA.IsBusy ) WScript.Sleep( 500 ); // check IsBusy every 0.5 second //NewA.Export( "test.html" ); // export result list to HTML file WScript.echo( "Exploration Completed" ); NewA.Close(); // close new Analysis } } catch ( err ) { WScript.echo( "Exception: " + err.message ); // display error that may occur }
Cool thanks for that got the "staticvarset" system going so far so if I have hassles moving forward I will fall back to the osaka plugin.
Then after closing AB and reopening on next day you can access them in IAB DB using mybuyprice = StaticVarGet( "NorgateDB_BuyPrice_" + GetFnData( "Alias" ) );
In Alias field of symbol's Information window of IAB DB you enter the name of the Norgate DB's according symbol in case it is different from IAB symbology. If symbol names are the same ones then use mybuyprice = StaticVarGet( "NorgateDB_BuyPrice_" + Name() );
If you know of a way of scripting AB to check if my saved watchlist(tickers) from Norgate DB are the same of different to IB's symbols would be great. Sometimes I will have 100+ symbols to check in the watchlist.
Thanx mate.
Cheers
procedure EraseWatchlist( listnum )
{
// retrieve comma-separated list of symbols in watch list
list = CategoryGetSymbols( categoryWatchlist, listnum );
//iterate through watchlist members and remove
for ( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ )
{
CategoryRemoveSymbol( sym, categoryWatchlist, listnum );
}
}
//sample use in Exploration
if ( Status( "stocknum" ) == 0 )
{
EraseWatchlist( WL = 0 );
}
Filter = Status( "lastbarinrange" );
SetOption("RefreshWhenCompleted", True);
procedure AddToWatchlist( listnum, List )
{
//iterate through symbol list and add to WL
for ( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ )
{
CategoryAddSymbol( sym, categoryWatchlist, listnum );
}
}
List = ... your saved comma separated list of wl members of Norgate DB ...;
//sample use in Exploration
if ( Status( "stocknum" ) == 0 )
{
AddToWatchlist( WL = 0, List );
}
Filter = Status( "lastbarinrange" );
SetOption("RefreshWhenCompleted", True);
I just thought of a different method where values can be immediately read back in IAB DB while Norgate is still open (or closed). That way uses the AmiBroker Osaka plugin (32-bit/64-bit).
The below AFL saves the buyprices during exploration or in chart pane (by opening param window and clicking button to export) in a binary file table (csv is possible too but not necessary).
Take a look at CategoryGetSymbols() to get comma separated list of symbols of a category (i.e. in Norgate DB). Then you can save that one by whatever method and call it in IAB DB.
As for syncing watchlist IMO you don't need to compare but just erase old watchlist in IAB and add saved symbols to same WL to update it. But I don't know what else you wanna do so ...
Anyway to clean a watchlist ( i.e in IAB DB)
Code:procedure EraseWatchlist( listnum ) { // retrieve comma-separated list of symbols in watch list list = CategoryGetSymbols( categoryWatchlist, listnum ); //iterate through watchlist members and remove for ( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ ) { CategoryRemoveSymbol( sym, categoryWatchlist, listnum ); } } //sample use in Exploration if ( Status( "stocknum" ) == 0 ) { EraseWatchlist( WL = 0 ); } Filter = Status( "lastbarinrange" ); SetOption("RefreshWhenCompleted", True);
To add symbols (i.e. from saved watchlist member list of Norgate DB)
Code:procedure AddToWatchlist( listnum, List ) { //iterate through symbol list and add to WL for ( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ ) { CategoryAddSymbol( sym, categoryWatchlist, listnum ); } } List = ... your saved comma separated list of wl members of Norgate DB ...; //sample use in Exploration if ( Status( "stocknum" ) == 0 ) { AddToWatchlist( WL = 0, List ); } Filter = Status( "lastbarinrange" ); SetOption("RefreshWhenCompleted", True);
Of course both codes can be combined to one execution in Exploration.
I'm back with another question.
I've been testing a system based on Nick Radge's Weekend Trend Trader. I'm OK with the basic code and have run some back-testing so I can see that the code is working.
One thing I can see is that there are times where the maximum positions (20 stocks) are all used. This means that no new positions can be taken until I exit some positions. Currently the only way I'm exiting is if the stop loss is exceeded which is triggered by either a 40% or 10% decline depending on the direction of the index.
What I'd like to look at is the option of selling positions when I've hit my max position size so I can free up capital to take up new positions. From looking at some charts I can see that some stocks have a good run that then flattens out. The stop loss condition isn't met so there's no sale, but the stock isn't increasing at the rate it once was. However, a new stock comes up on the radar that (potentially) could have better growth over the short term. I'd prefer to purchase this new stock and sell the existing, slower-moving one.
However, if there's no new 'buy' signals for the week, keep holding all the stocks. I'll assume that even a slow growth rate could be better than a cash return.
I know I can do this manually, but I want it as part of the system so I can back test it and see if it makes any difference.
So what I'm trying to understand, is how do I code the following:
- If maximum positions are taken up AND there's a new 'buy'
- Find the stock that the portfolio is currently holding that has the lowest Rate Of Change over the past 30 days.
- Sell that stock
- Use the sale proceeds to purchase the new 'buy'.
Hopefully this isn't a silly question and there's a way to do it.
Thanks in advance for your help.
I'm back with another question.
I've been testing a system based on Nick Radge's Weekend Trend Trader. I'm OK with the basic code and have run some back-testing so I can see that the code is working.
One thing I can see is that there are times where the maximum positions (20 stocks) are all used. This means that no new positions can be taken until I exit some positions. Currently the only way I'm exiting is if the stop loss is exceeded which is triggered by either a 40% or 10% decline depending on the direction of the index.
What I'd like to look at is the option of selling positions when I've hit my max position size so I can free up capital to take up new positions. From looking at some charts I can see that some stocks have a good run that then flattens out. The stop loss condition isn't met so there's no sale, but the stock isn't increasing at the rate it once was. However, a new stock comes up on the radar that (potentially) could have better growth over the short term. I'd prefer to purchase this new stock and sell the existing, slower-moving one.
However, if there's no new 'buy' signals for the week, keep holding all the stocks. I'll assume that even a slow growth rate could be better than a cash return.
I know I can do this manually, but I want it as part of the system so I can back test it and see if it makes any difference.
So what I'm trying to understand, is how do I code the following:
- If maximum positions are taken up AND there's a new 'buy'
- Find the stock that the portfolio is currently holding that has the lowest Rate Of Change over the past 30 days.
- Sell that stock
- Use the sale proceeds to purchase the new 'buy'.
Hopefully this isn't a silly question and there's a way to do it.
Thanks in advance for your help.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?