Herman,
Thanks for the reply. I thought about making a reference, but it would have to be updated every 5 seconds with a new bar and the whole thing written out again with ATC, and that would take too long even if I knew how to do it.
The real solution would be to have a fake reference ticker in the local database that makes a new bar at every interval. This should be quite easy! --I just put that in there to make Tomasz cringe ;-)
Seriously though, a time reference ticker in the local database would be an ideal solution and it would not require any changes to AB or AFL to make it work --just a special ticker symbol. SetBarsRequired() could guarantee you get as many bars as you need.
Did you put in a request for this? Oh, I see that you did in feature request #807 --I will vote for it ten times over.
Optionally, I guess that AB could recognize a special ticker name and instead of going to the database, just create the bars on the fly. Another way would be to have a preference that would pad and align all data to an ideal reference --though I would rather it be something like a parameter in SetBarsRequired() that would turn this on and off.
Several possible ways to do this someday, but I only have a week before my current method fails. I can live with holes as long as every bar that is in both contract tickers is in the array. Is there a way to merge the two tickers in an indicator to cover all bars in both?
Best regards, Dennis
On Dec 18, 2007, at 4:00 PM, Herman wrote:
I think you are looking for a continuous DateTime reference array; there is no such thing in AmiBroker. No matter how carefully you manage your data there will be holes. The need for such a reference array is outlined in a post on Data Holes in Real-Time Trading One way of constructing it is using the calculations outlined in the posts Time calculations and Date Calculations . The calculations are intensive and timeconsuming. The reference arrays calculated would have to be stored in Composite files created with the AddToComposite(). I found the calculations and use of composites too slow for us in real time trading with with 5 second data. I was using up to 500,000 bars. There were some discussions on this list on this topic however the best suggestion that surfaced was to do the calculations off line, and import the data with the import wizard. However this process doesn't help the real time trader.
Season's Greetings, herman
For tips on developing Real-Time Auto-Trading systems visit:
Tuesday, December 18, 2007, 3:37:38 PM, you wrote:
> Hi all,
> I needed to have a months worth of ES (S&P 500 eMini) 5 second data > for my backtesting. eSignal only provides 10 days of backfill though > for the 5 second data. They have a continuous contract, but when it > rolls over it changes the oldest prices, so it would have to be > backfilled. I have collected 200K bars of the December contracts > which just rolled to the March contracts.
> I wrote an AFL to produce a continuous contract for ES by combining > the two contracts into an ATC ticker (~ES). Then I use this ticker > to run my real time indicator chart of ES. I have only run into two > problems. The first is it takes almost one second to run the AFL to > generate the real time contract ticker. The second is I need to have > that chart ticker pointing to something that has all the 5 second > bars for 30 days back in order for the other two contracts to have a > place to store their quotes (using foreign). I don't have such a > beast. The closest I can come is to use the oldest contract ticker > which will work for a week until the contract expires.
> With all that background, here are my questions:
> Is there a faster and easier way to do this?
> I need all the bars in both the two contract tickers to merge them. > How do I get all the bars I need to make my 200K bar ATC ticker?
> Thanks for your help. Here is my AFL.
> //////////////////////////////////////////////////////////////////////// > /// > // Continious Contract on 5 sec database (by Dennis Brown 12/16/2007) > // > // This chart is used to generate Continious Contract data for > another chart. > // This runs on a 5 second database to merge contract prices and volume. > // Last quarters contract prices are adjusted down by the premium. > // Volumes are just added. > // Merged data is saved to "~ES" ATC ticker every pass. > // Edit the Tick size: .25, and Point value: 50 for the ~ES ticker > // Other chart must use the ticker "~ES". > // > // set the realtime data also using static variables > // "bidRT","askRT","lastRT"
> Version(5.0); //minimum version required > SetChartOptions(2,chartShowDates); > SetBarsRequired(1000000,1000000); > tick = TickSize; if(tick==0){tick=.01;} > flag=0;
> function StaticArraySet(VarName,array){AddToComposite > (array ,"~SA_"+VarName ,"X",atcFlagEnableInIndicator|atcFlagDefaults);}
> //ChartTicker = StaticVarGetText("ChartTicker"); //name from main chart
> //if(ChartTicker =="~ES"){ > ATCname="~ES"; OldContract="ES Z7"; NewContract="ES H8"; flag=1; > //} > if(flag) > { > SetForeign(OldContract); //older ticker > O1=O; H1=H; L1=L; C1=C; V1=V; > Title=OldContract + " Through "+ NewContract; > SetForeign(NewContract); //newer ticker > diff = MA((H1+L1)/2,2160) - MA((H+L)/2,2160); //3 Hour average price > difference > Vxover = MA(V,17280) > MA(V1,17280); //24 hr ave volume crossover > for(i=BarCount-1; i>0 AND Vxover[i]==1; i--){V[i]+=V1[i];} //add > both volumes together > delta = round(diff[i]*(1/tick))/(1/tick); //move to closest tick > for(i=i; i>=0; i--) > {O[i]=O1[i]-delta; H[i]=H1[i]-delta; L[i]=L1[i]-delta; C[i]=C1[i]- > delta; V[i]+=V1[i];} //offset old array bars
> AddToComposite(O ,ATCname ,"O",atcFlagEnableInIndicator| > atcFlagDeleteValues); > AddToComposite(H ,ATCname ,"H",atcFlagEnableInIndicator); > AddToComposite(L ,ATCname ,"L",atcFlagEnableInIndicator); > AddToComposite(C ,ATCname ,"C",atcFlagEnableInIndicator); > AddToComposite(V ,ATCname ,"V",atcFlagEnableInIndicator);
> StaticVarSet("bidRT",GetRTDataForeign("Bid",NewContract)); > StaticVarSet("askRT",GetRTDataForeign("Ask",NewContract)); > StaticVarSet("lastRT",GetRTDataForeign("Last",NewContract)); > } > //Plot(C,"",IIf(Vxover,colorBlack,colorRed),styleBar); > //Plot(V,"",colorLightGrey,styleHistogram|styleOwnScale); > RequestTimedRefresh(2,0); |