Visit our COVID-19 site for latest information regarding how we can support you. For up to date information about the pandemic visit www.sacoronavirus.co.za.

bs-regular
bs-extra-light
bs-light
bs-light
bs-cond-light-webfont
bs-medium
bs-bold
bs-black

Community


Share knowledge. Ask questions. Find answers.

Online Share Trading

Engage and learn about markets and trading online

AFL coding for amibroker

Reply
Nick_1
Frequent Contributor
Hey Tango, see you hanging around at this hour. Are you ok with setting up your system in AFL in Amibroker? Man it's a b@tch, I dont see too many examples in the help files and have no programming background! So cant even get conditional settings to work! Any suggestions on where to find more samples or pointers?
0 Kudos
12 REPLIES 12
Tango
Super Contributor
hi Nick - mail me at [email protected] and we can chat AFL. I have fiddled around in AFL, but haven't bother to completely automate everything. My system is a combo of indicators, a position-sizing spreadsheet, and an automatic way of calculating a trailing stop that takes volatility into account but contracts the stop level when the share is trending (Elder's Safestop). The whole lot has not been tested together and is only going into practice from this year. Backtesting the system showing promising prospects, but we'll see what happens in the real world. I figure the key elements of an effective system are money management, triggers, and stops. And a set of rules - eg, no doubling-down, trade with the primary trend, alway obey stops and other generally good practices.
0 Kudos
cfm
Super Contributor
There are a library of available functions on the Amibroker web site. They don't have explainations, so you have to figure it out yourself. You can always ask here.
0 Kudos
Nick_1
Frequent Contributor
Yep, thanks for the replies. Checked the website as well in the past. It is more in trying to understand how to set it up. I see they have a Tool for 49USD that you can use to write out your requirements and it then codes it for you. Pretty neat. Will try on my own for a while and then perhaps get their converter tool. Main issue at the moment is that I want to compare today's close for instance with yesterdays close. it would be something like - CLOSE > CLOSE (Yesterday or past month). It is the yesterday close im struggling with. There's a HHV function but it will include today's close as well and I dont want today's but yesterday. Thanks Cheers.
0 Kudos
cfm
Super Contributor
To get yesterdays close use Ref(C,-1). Ref moves the array specified as the first parameter (close in this instance) by a number of bars (-1 in this instance).
0 Kudos
Nick_1
Frequent Contributor
Ah Brill!! Thanks cfm, will test that one. IF -1 will give you previous day, what will give you previous 10,20 or 30 days? Your help is much appreciated! Cheers
0 Kudos
cfm
Super Contributor
Use -10, -20 or -30 to get the price 10, 20 or 30 bars (days) ago. It will be trading days and not physical days. So, weekends and public holidays or days with missing data does not count.
0 Kudos
bliksempie
New Contributor
You could also try using the Rate Of Change indicator: "This indicator displays the rate−of−change of a security's price. Change is displayed as a percentage rather than as a ratio. ROC is calculated by dividing the price change over the last n−periods by the closing price n−periods ago. This gives you percentage that the price has changed in the last n−periods." - Amibroker User's guide. Usage: ROC(C,10); //this gives you the percentage rate of change in closing price over the last 10 days... G'luck I wont be around for the next week or two, but post a question if u have any, you can also ask tango, he knows where to get hold of me.
0 Kudos
Nick_1
Frequent Contributor
Thanks B! Will look into that one. And cfm, With my 2nd Q regarding your Ref-pointer I actually were thinking of somekind of range i.e. past 5 days, past month etc. and not point in time in history. Will look at Ref tonite and see if it holds the key. Or try Bs ROC. Out of interest have you guys programmed your own system into Ami? At what sort of level? Just to id your triggers or actually to manage your stops, position sizing etc? Ive seen Tango saying his on trigger level with the rest in spreadsheets?
0 Kudos
cfm
Super Contributor
Yep, my system is coded in Ami. Draws a arrow on the chart indicating buy or sell point. I then eyeball the graph and see if I agree or not.
0 Kudos
Nick_1
Frequent Contributor
Howzit cfm. Well Im getting there in babysteps and enjoy the learning curve. Last night I managed to get the part I was struggling with to work using your REF in combo with HHV. Now Im replicating my buys I did in excel exactly in AMI. At this stage Im still exporting the buy signals to excel and work on it from there, but will start to incorporate the chart signals, stop losses etc. Plenty of examples that can be used within the afl-systems to get the columns and graph interfaces going.
0 Kudos
Nick_1
Frequent Contributor
Also interested in checking out the impact of Chartist's ADX referral. Ive added ADX(20) to my code but it does not have any impact on the buy signals? Perhaps it should be with a > than or so. Havent tried - ADX(20) > 20 -, would that be the correct script?
0 Kudos
cfm
Super Contributor
ADX required a lookback period. So you must do something like ADX(lookback) > threshold to use it. Maybe Buy=ADX(14)>20 AND .....
0 Kudos