Ed:
That works, but I'm concerned about following from user guide:
"It may slow down backtest/exploration/scan and introduce some slight changes
to indicator values when your data has holes and holes are filled with previous
bar data. The feature is intended to be used when your system uses general
market timing (generates global signals based on data and/or indicators
calculated using Foreign from 'reference' symbol)"
This is exactly what I'm doing, but I'm concerned with backtesting system. Say
I've created a global market filter that I incorporate into various trading
systems. If it is a rotational system and the various symbols are padded, will
it not (possibly) create false signals. (If a particular symbol was not padded
- had no quotes - I assume it will not be included in positionscore
calculations, etc.
Assuming these effects are negligable, is there a way to turn 'Pad and align'
on from code, or just the settings window?
The solution I had before reading your message was to always determine a date
that each symbol had a quote for in watchlist, and then calculate global market
filter from that date forward. (The only reason I've had to do this is to
calculate A/D Line because my FastTrack data source offers symbol with NYSE
advances and symbol with NYSE declines.) From this, I calculate AD Line as
follows:
//to determine bar # of specific date
d = 10000 * (2008-1900) + 100 * 1 + 11;
DT = DateNum();
for ( z = 0; z < BarCount; z++ )
{
if ( DT[z] == d )
{
break;
}
}
//calculate AD Line from that date forward
a = Foreign( "$NADV", "Close" );
d = Foreign( "$DECL", "Close" );
ad[z] = ( a[z] - d[z] ) + 100000;
for ( i = z+1;i < BarCount;i++ )
{
ad[i] = ( a[i] - d[i] ) + ad[i-1];
}
This method seems very convoluted (mostly because I'm a rookie programmer.)
I'm also realizing that if I want to backtest watchlist from beginning of
database (approx 1988), I won't have ADLine.
I guess it all comes down to my original question of barcount with foreign
symbol. Say one of symbols in watch list only has data for last 5 years, when
I got to reference foreign data ($NADV - advances or $DECL - declines, which
have quote history back to 1988), I get a different value for ADLine because of
initially adding that 100000 to variable ad.
I know this is long winded. I appreciate anyone taking time to read and
respond.
Also, if there is a much cleaner or simpler way to do above code, please let me
know.
Thanks,
Levi
--- In [email protected], "Edward Pottasch" <empotta...@...> wrote:
>
> what you might try (not sure if it will work): In the backtester settings
> window use: "Pad and align all data to refence symbol". Then choose a symbol
> used for reference of which you have many data and is also considered as a
> "benchmark" (for instance ES for futures),
>
> Else, make sure that your active window contains the "benchmark" data.
>
> rgds, Ed
>
>
>
>
> ----- Original Message -----
> From: levibreidenbach
> To: [email protected]
> Sent: Tuesday, October 27, 2009 12:26 AM
> Subject: [amibroker] Re: BarCount with foreign symbol
>
>
> Hi Rob:
>
> I've tried that. SetBarsRequired() at beginning of code.
>
> Then, when I set foreign, it still only utilizes 200 bars of the 1104.
> At least I assume this is what is happening. Whatever the issue is,
> calculation comes out different depending on active symbol.
>
> Let me explain what I'm doing:
>
> Using FastTrack data, I have symbol for NYSE Advances and symbol for NYSE
> Declines. I am trying to calculate A/D Line from these two symbols.
>
> Here's the code:
>
> a = Foreign( "$NADV", "Close" );
> d = Foreign( "$DECL", "Close" );
>
> ad[0] = ( a[0] - d[0] ) + 10000;
>
> for ( i = 1; i < BarCount; i++ )
> {
>
> ad[i] = ( a[i] - d[i] ) + ad[i-1];
>
> }
>
> The problem I have is depending on which symbol is the active symbol, the
> calculation comes out different. I'm assuming this is because not all symbols
> have same amount of history.
>
> I would like to be able to calculate this A/D Line same no matter what
> symbol in use as I use it for filter in backtests.
>
> Thanks for help
>
> Levi
>
> --- In [email protected], "Rob" <sidhartha70@> wrote:
> >
> > You can use SetBarsRequired() and make it do whatever you want...
> >
> > --- In [email protected], "levibreidenbach" <levib1@> wrote:
> > >
> > > If the active symbol has a barcount of 200, and I then use setforeign
> function to work with another array (which has a barcount of 1104), will I be
> able to access all 1104 bars, or only the 200 because that is what is
> initially loaded?
> > >
> > > The reason I would like to access all bars is to loop through them and
> do some calculations that I would like to be the same for all symbols. These
> calculations are based on a specific starting value (say 10,000), and if I
> start calculation at the 'zero' bar and barcount is different for each
> symbol, the calculation is always different for different symbols.
> > >
> > > I know I didn't explain this too well, but any help would be
> appreciated. If I can clarify anything, let me know.
> > >
> > > Thanks
> > >
> > > Levi
> > >
> >
>