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

Re: [amibroker] Re: Excluding last trades



PureBytes Links

Trading Reference Links

Thanks Walt, however it seems my off the cuff code I wrote in the
email works well with minor mods.

What I am trying to do in the bigger picture is set up an intraday map
of volume and volatility.
I did a long handed code to isolate the time zones and then average
the volumes over all the data for each time zone. However because long
hand method it is not flexible for changing the timeframe periods.

first I created a composite of the stock group
UseTrade = TimeNum() <= ValueWhen( Cross( TimeNum(), 160001 ), TimeNum() );

function tick( price )
{ ticks = round( Min( price, 0.1 )/0.001 + Max( ( Min( price, 0.5
)-0.1 ) ,0 )/0.005 + Max( price-0.5 ,0 )/0.01 ); return ticks; }

// ticks are for the ASX market pricing structure

function price( ticks )
{ prices = Min( ticks, 100 )*0.001 + Max( ( Min( ticks, 180 )-100 ) ,0
)*0.005 + Max( ticks-180 ,0 )*0.01 ; return prices; }

Hc = tick(H)-tick(L)+1;

Vc = V*C/1000;
Buy=1;
Comp="~ASX100";
AddToComposite(Hc*usetrade,Comp,"H",1+2+4+16);
AddToComposite(Vc*usetrade,Comp,"V",1+2+4+16);
AddToComposite(1*usetrade,Comp,"I",1+2+4+16);



then plotted this for the composite ticker

numdays = Cum(DateNum()!=Ref(DateNum(),-1));

p0 = TimeNum()<100000;
p1 = TimeNum()>=100000 AND TimeNum()<103000;
p2 = TimeNum()>=103000 AND TimeNum()<110000;
p3 = TimeNum()>=110000 AND TimeNum()<113000;
p4 = TimeNum()>=113000 AND TimeNum()<120000;
p5 = TimeNum()>=120000 AND TimeNum()<123000;
p6 = TimeNum()>=123000 AND TimeNum()<130000;
p7 = TimeNum()>=130000 AND TimeNum()<133000;
p8 = TimeNum()>=133000 AND TimeNum()<140000;
p9 = TimeNum()>=140000 AND TimeNum()<143000;
p10 = TimeNum()>=143000 AND TimeNum()<150000;
p11 = TimeNum()>=150000 AND TimeNum()<153000;
p12 = TimeNum()>=153000 AND TimeNum()<160000;
p13 = TimeNum()>=160000 AND TimeNum()<163000;
p14 = TimeNum()>=163000;

VOI = V;//OI;

V0 = Cum( IIf( p0, VOI, 0 ) );
V1 = Cum( IIf( p1, VOI, 0 ) );
V2 = Cum( IIf( p2, VOI, 0 ) );
V3 = Cum( IIf( p3, VOI, 0 ) );
V4 = Cum( IIf( p4, VOI, 0 ) );
V5 = Cum( IIf( p5, VOI, 0 ) );
V6 = Cum( IIf( p6, VOI, 0 ) );
V7 = Cum( IIf( p7, VOI, 0 ) );
V8 = Cum( IIf( p8, VOI, 0 ) );
V9 = Cum( IIf( p9, VOI, 0 ) );
V10 = Cum( IIf( p10, VOI, 0 ) );
V11 = Cum( IIf( p11, VOI, 0 ) );
V12 = Cum( IIf( p12, VOI, 0 ) );
V13 = Cum( IIf( p13, VOI, 0 ) );
V14 = Cum( IIf( p14, VOI, 0 ) );

Vsum = V0*P0 + V1*P1 + V2*P2 + V3*P3 + V4*P4 + V5*P5 + V6*P6 + V7*P7 +
V8*P8 + V9*P9 + V10*P10 + V11*P11 + V12*P12 + V13*P13 + V14*P14;

Vcum = Vsum/numdays;

mycolor=IIf(Hour()<12, colorBlue,
 IIf(Hour()>=12 AND Hour()<14,colorRed,
 IIf(Hour()>=14 AND Hour()<16,colorGreen,
 colorBlack)));

Plot(Vcum, "Vchange", mycolor, styleArea);


However I want to vary the timeframe on screen so need something mre flexible
I started using a loop structure but can't seem to get my head around
how to work it with the loops on bars and intervals

numdays = Cum(DateNum()!=Ref(DateNum(),-1));
numint = (6*60+15)*60/Interval();
Tx = TimeNum();
x = 0;
timex = 100000 + int(Interval()*x/3600)*10000 + (Interval()*x/60)%60*100;
p[0]=0;

for(x=1;x<=numint;x++)
{
 p[x] = Tx[x]>=timex[x-1] AND Tx[x]<timex[x];
}




On Sat, 12 Mar 2005 13:22:58 -0000, hairy_mug <WSCHWARZ@xxxxxxxxxxxxx> wrote:
> 
> 
> I'll give you a hand if you can spell out the requirements...
> 
> if <condition>
> then <step>
> 
> ...don't need syntax, just steps...
> 
> walt
> 
> --- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@xxxx> wrote:
> > The ASX has a market auction similar to pre-open to determine the
> > official close price. The closing is then timed against ticker
> > alphabet to stagger them, like market opens. Then ther are the after
> > market trades beyond this time. It gets more complex as on the last
> > trade day of each month the auction time is longer.
> > So normal close would be between 4:05 and 4:08pm, then at month end
> > 4:10 to 4:13pm. These times for example of what happens.
> >
> > I want to include the actual last trades of official market, and
> > exclude any further after amrket trades/transfers. There are no
> trades
> > between 4:00pm and the auction close. Of course there are also cases
> > of no trades after 4pm.
> >
> > Can anyone help with how to write this in AFL.
> > something like
> >
> > LateTrade = timenum()== valuewhen( cross( timenum(), 160001 ),
> timenum() );
> > UseVol = V * LateTrade;
> >
> > just not sure how to make certain all the above requirements are
> met.
> >
> > TIA
> >
> > --
> > Cheers
> > Graham
> > http://e-wire.net.au/~eb_kavan/
> 
> 
> 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 Links
> 
> 
> 
> 
> 


-- 
Cheers
Graham
http://e-wire.net.au/~eb_kavan/


------------------------ Yahoo! Groups Sponsor --------------------~--> 
What would our lives be like without music, dance, and theater?
Donate or volunteer in the arts today at Network for Good!
http://us.click.yahoo.com/Tcy2bD/SOnJAA/cosFAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

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 Links

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

<*> 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/