[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Intraday Data - SetForeign and data alignment



PureBytes Links

Trading Reference Links

I'm not sure where the problem is and I think there is more than one problem to solve. My assumption at present is that I have done something really silly. I hope someone can help me out.
 
I have constructed a volume calculation for Aussie sector indexes using the SetForeign function. The code works great on EOD local data (even where some of the constituent stocks have missing bars) BUT it performs totally differently for intraday data.
 
Data sources tested:
A. EOD Data only
B. Marketcast RT plugin (1 minute data local storage in AB)
C. Local data store of 1 minute data
 
Cut down version of the code is provided at the base of this post.
 
On EOD data, whilst displaying XIJ, the volume indicator provides a summation of each days volume as a histogram and details the individual volumes in the interpretation section. I consciously delete a couple of daily bars for CPU and the code correctly replaced the gaps with zero volume for that period.
 
However, when switching to the intraday databases, holes suddenly appear in the data when each constituent ticker has valid data for that period. i.e. if I display the daily price/volume chart for each ticker, the code below shows the correct volume for today for the same ticker (and every period as there are no missing days in the data for any ticker). However there are zero volume values for some of the other tickers 9depending on which bar is selected) even though individually each has volume for that day.
 
It is very hard to describe, so I hope someone understands what I am getting at. It appears to me that when the intraday data is compressed to provide daily bars, some empty bar characteristics may be propogating to a daily bar, but only when accessed via GetForeign. Or rather, I have made an obvious and silly coding error. I truly hope it is the later. What concerns me is that I cannot replicate the problem on the EOD data whilst viewing daily/weekly/monthly charts. But it is easily reproduced using daily/30 minute/weekly etc charts with a 1 minute database. Note that the tickers DO have gaps between 1 minute bars as the stocks are not continuously traded. This is the norm for Aus as mentioned in a recent query on pitch forks.
 
The code below allows for fill to be enabled, this produces some more interesting (but undesirable) effects which deserve their own post. Once again, I hope it is my code that has stuffed up (and easily rectified). But one problem at a time.
 
regards
Chris (Shawky)
 
P.S. I really like the new formula environment, include files, parameter options etc, drag and drop, especially the insert linked facility. Looking forward to an Overlay Linked option in the future ;)
The code:
 
PadEmptyBars=ParamToggle("Pad Empty Bars","No|Yes",0);
tickers="CPU,BCA,IRE,VSL";
MyVol = 0;
for ( num = 0; ( sym = StrExtract(tickers,num) ) != "" ; num++)
{
 if ( SetForeign(sym,PadEmptyBars) )
 {
  VarSet("Vol"+num, IIf(IsNull(V),0,V) );
  RestorePriceArrays();
 }
 else
 {
  printf("Ticker "+sym+" not found\n");
  VarSet("Vol"+num, 0);
 }
}
 
for ( i = 0; i < num; i++ )
{
 MyVol = MyVol + VarGet("Vol"+i);
}
 
Plot( MyVol, _DEFAULT_NAME(),
 IIf( C > O, ParamColor("Price Up Color", colorLightGrey ), ParamColor("Price Down Color", colorGrey50 ) ),
 ParamStyle( "Price Style", styleHistogram | styleThick | styleOwnScale, maskHistogram  )
 );
 
for ( i = 0; i < num; i++ )
 printf(  " " + StrExtract(tickers,i) + " " + WriteVal(VarGet("Vol"+i),10.0)  + "\n");
 
 


Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For other support material please check also:
http://www.amibroker.com/support.html




Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links