- Joined
- 1 November 2009
- Posts
- 424
- Reactions
- 67
Thanks Superglue but I am trying to name the cells eg. in your cell C3, you can name the cell by Insert>Name>Create and type aac_open. Easy enough to do for a few cells but not 6000 times.
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
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.
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.
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
thanks for the reply bingk6
Any chance you could steer me in the general direction I'd need to look to do this?
20dayhigh = H == hhv(H,20);
AddToComposite(20dayhigh,"~~~20dayhigh","C",atcFlagDefaults|atcFlagEnableInBacktest|atcFlagEnableInPortfolio);
//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);
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.
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.
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?