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

[amibroker] Need some help with ATC and making continuous contract futures



PureBytes Links

Trading Reference Links

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);


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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/