Australian (ASX) Stock Market Forum

Amibroker FAQ

morning folks, just have a quick question about composites. I've put together a couple of composite breadth indicators on the NYSE. What I usually do is update it each day when I get the final edition data from premium data by running a scan in AA, and in the 'range' box, tick 'n last days' with a setting of 1. Unfortunately when I run the scan it isn't just running the scan on the last day and seems to be adjusting prior records. data in the composite for the past few days is now slightly different to reflect a couple of delistings on the NYSE overnight, which was exactly what I was trying to avoid by running the scan for only the past day.

Is there something I'm missing or doing wrong? When I update the composite I'd like it to only actually update the days that I specify. Or is that not possible?
 
This will always be an issue when you try and do retrospective lookups. It's not possible in any charting program that I know of to specify something like "add up the volume of all of the stocks on the NYSE for a given date but make sure all stocks that were listed on the NYSE on that day are included, even if they are now delisted or trading on another exchange"

Perhaps you don't need them anyway... try looking at the following symbols:

Cumulative Advance Decline Line: #NYSEAD
Advancing stocks & volume: #NYSEADV
Declining stocks & volume: #NYSEDEC
Unchanged stocks & volunme: #NYSEUNC
Advance Decline Ratio: #NYSEADR
Advance Decline Volume Ratio: #NYSEADR
New Highs: #NYSENH
New Lows: #NYSENL
 
This will always be an issue when you try and do retrospective lookups. It's not possible in any charting program that I know of to specify something like "add up the volume of all of the stocks on the NYSE for a given date but make sure all stocks that were listed on the NYSE on that day are included, even if they are now delisted or trading on another exchange"

Perhaps you don't need them anyway... try looking at the following symbols:

Cumulative Advance Decline Line: #NYSEAD
Advancing stocks & volume: #NYSEADV
Declining stocks & volume: #NYSEDEC
Unchanged stocks & volunme: #NYSEUNC
Advance Decline Ratio: #NYSEADR
Advance Decline Volume Ratio: #NYSEADR
New Highs: #NYSENH
New Lows: #NYSENL

Hi Richard, thanks for the reply

I do use most of the breadth info that you guys provide, and quite like them:)
What do you mean by retrospective lookups?
 
By retrospective I mean having the ability to look at the database as it would have been on day X.

Code changes, exchange shifts, transfers to OTC stocks (and back), additional exchanges (eg. NYSE Arca) obviously affect your ability to calculate any market breadth indicators on the basis of today's current database. You would be introducing survivorship bias into any creation of such indicators.

I'm leaning towards looking at historical index constituents and creating market breadth indicators from them, but that's a whole new project that would take a while.
 
By retrospective I mean having the ability to look at the database as it would have been on day X.

Code changes, exchange shifts, transfers to OTC stocks (and back), additional exchanges (eg. NYSE Arca) obviously affect your ability to calculate any market breadth indicators on the basis of today's current database. You would be introducing survivorship bias into any creation of such indicators.

I'm leaning towards looking at historical index constituents and creating market breadth indicators from them, but that's a whole new project that would take a while.

Ok I get you now. That's the sort of thing I'm trying to avoid! The indicator I was updating was looking at 20 day highs and lows for common stocks on the NYSE. To try and avoid any problems I wanted to update today's records only, but what ami is doing is updating days before the most recent one. For example, looking at common stocks on the NYSE, 2 days ago there were 250 of them trading at a 20 day low. 2 of the companies that were showing results in that scan delisted when I got the final update today, and when I ran the scan to update the composite indicator for today only, the result from 2 days ago now shows 248.
 
Look up "Dynamic Named Range" on Google.

Thanks again Superglue. I've had a wee look into dymanic named range but it seems primarily aimed at a group or list of cells that can be named together under one name. Unfortunately my programming knowledge is very limited. I think I need a macro that allows a generic ticker_last to be substituted by the ticker name in the first column of each row.
 
Thanks again Superglue. I've had a wee look into dymanic named range but it seems primarily aimed at a group or list of cells that can be named together under one name. Unfortunately my programming knowledge is very limited. I think I need a macro that allows a generic ticker_last to be substituted by the ticker name in the first column of each row.

Try this link:
http://webcache.googleusercontent.c...+dynamic+named+range&cd=1&hl=en&ct=clnk&gl=au

You'll have to use the "offset" and the step by step example.
 
Ok I get you now. That's the sort of thing I'm trying to avoid! The indicator I was updating was looking at 20 day highs and lows for common stocks on the NYSE. To try and avoid any problems I wanted to update today's records only, but what ami is doing is updating days before the most recent one. For example, looking at common stocks on the NYSE, 2 days ago there were 250 of them trading at a 20 day low. 2 of the companies that were showing results in that scan delisted when I got the final update today, and when I ran the scan to update the composite indicator for today only, the result from 2 days ago now shows 248.

Prof,

From my experience, the scan function takes no notice of the date range that you specify. You can specify the last day, last 2 days or last month and the array you get out of it will be the same.

If I understand your problem correctly, this is what you need to do

1) Amend your code so that the scan operation writes out to a new array (call it x)
2) Run your scan operation so that x is the array that the scan operation writes it output to
3) Assign just the last element of x, ie x[barcount-1] back to the last element in the original composite.

haven't actually done it, but all three steps above should be able to be performed within a single AFL.

This way, as you run your scan each day, you'll slowly accumulate your composite, with only the last element updated on a daily basis and everything else will remain unchanged
 
Prof,

From my experience, the scan function takes no notice of the date range that you specify. You can specify the last day, last 2 days or last month and the array you get out of it will be the same.

If I understand your problem correctly, this is what you need to do

1) Amend your code so that the scan operation writes out to a new array (call it x)
2) Run your scan operation so that x is the array that the scan operation writes it output to
3) Assign just the last element of x, ie x[barcount-1] back to the last element in the original composite.

haven't actually done it, but all three steps above should be able to be performed within a single AFL.

This way, as you run your scan each day, you'll slowly accumulate your composite, with only the last element updated on a daily basis and everything else will remain unchanged

thanks for the reply bingk6:)

Any chance you could steer me in the general direction I'd need to look to do this?
 
thanks for the reply bingk6:)

Any chance you could steer me in the general direction I'd need to look to do this?

OK, try this. Assuming that your original code to create the composite looks like the following
Code:
20dayhigh = H == hhv(H,20);	
AddToComposite(20dayhigh,"~~~20dayhigh","C",atcFlagDefaults|atcFlagEnableInBacktest|atcFlagEnableInPortfolio);

Then amend the code to the following
Code:
//take a backup
backupcomposite = foreign("~~~20dayhigh","C"); 

//create temp composite
20dayhigh = H == hhv(H,20);	
AddToComposite(20dayhigh,"~~~temp","C",atcFlagDefaults|atcFlagEnableInBacktest|atcFlagEnableInPortfolio); 
temparray = foreign("~~~temp","C");

//update last element of backup composite and write it back to the original composite
backupcomposite[barcount-1] =  temparray[barcount-1]; 
AddToComposite(backupcomposite,"~~~20dayhigh","C",atcFlagDefaults|atcFlagEnableInBacktest|atcFlagEnableInPortfolio);

Note that with V5.30, you can infact use static array variables and the temp composite that I created above can in fact be created using static array variables instead of writing out another composite.

BTW, I have not tested the code, just off the top of my head. Let us know how you go.
 
OK, try this. Assuming that your original code to create the composite looks like the following
Code:
20dayhigh = H == hhv(H,20);	
AddToComposite(20dayhigh,"~~~20dayhigh","C",atcFlagDefaults|atcFlagEnableInBacktest|atcFlagEnableInPortfolio);

Then amend the code to the following
Code:
//take a backup
backupcomposite = foreign("~~~20dayhigh","C"); 

//create temp composite
20dayhigh = H == hhv(H,20);	
AddToComposite(20dayhigh,"~~~temp","C",atcFlagDefaults|atcFlagEnableInBacktest|atcFlagEnableInPortfolio); 
temparray = foreign("~~~temp","C");

//update last element of backup composite and write it back to the original composite
backupcomposite[barcount-1] =  temparray[barcount-1]; 
AddToComposite(backupcomposite,"~~~20dayhigh","C",atcFlagDefaults|atcFlagEnableInBacktest|atcFlagEnableInPortfolio);

Note that with V5.30, you can infact use static array variables and the temp composite that I created above can in fact be created using static array variables instead of writing out another composite.

BTW, I have not tested the code, just off the top of my head. Let us know how you go.

I ran the code and what I got was no values up until today and then a value of 676,000 for some reason:confused:
 
I am rather new to Amibroker and I have ran into a problem with backtesting.
I am using a variety of values (eg. X,Y &Z) to produce buy signals. When I run the backtest, I want to see these values (X,Y &Z) t listed as columns as it will immensely help in fine tuning the values, by comparing them against the profit of the trade.

I have researched a few possibilities, which have came to a dead end.
I can't use addColumn as that is only for exploration.

I have looked into using trade.AddCustomMetric() but that only seems to access trade specific values. I know there is signal object in the backtest but couldnt find a method to access these values used to generate the signals.

Am I going about it the wrong way, and you need to run an exploration then export the results to Excel have it use a function to find the sold price, and then calculate the profit.

Thanks
 
Hi,

Is anyone here able to help me with this?

I want some code to test all periods (between say 10 – 100) of StdErr(C,periods), and return the periods value that produces the lowest StdErr?

thanks
 
Hello,

I've done a search of forum threads and haven't been able to find the answer to this question so apologies if this has already been answered:

Can Amibroker do scans based on fundamentals (i.e. scan for stocks with a certain P/E ratio, Debt-Equity Ratio, dividend yield, etc)?

Also can it pull this fundamental data from somewhere like eTrade? Or at the very least, some other reputable data source on company fundamentals?

Thanks for your help.
 
alterego,

standard error can be used as your optimization target under: AA>settings>walkforward>target

Then you would have to write code for the optimization, say for example...

buy = cross ( c, optimize(.... etc.

Remember to use cmae engine to optimize.
 
alterego,

standard error can be used as your optimization target under: AA>settings>walkforward>target

Then you would have to write code for the optimization, say for example...

buy = cross ( c, optimize(.... etc.

Remember to use cmae engine to optimize.

Sorry, maybe I wasn't clear. I don't want to optimise standard error in a backtest. I want to use it in an exploration. So for each stock in the exploration results I want it to select the "best fit" linear regression periods length (ie. the periods that produces the lowest standard error value for that stock). Every stock will have a different "best fit" value.
 
Top