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

RE: [amibroker] help---day counter (intraday avg vol) question



PureBytes Links

Trading Reference Links

Merry Christmas...and because it's Christmas I only have time for a little help…After spending more time than I have you need to re-think your solution based on my (incomplete) observations as follows:

 

You have not used subscripts in your loop. This is required as loops deal with all numeric variables. Said another way, you must deal with one bar at a time. Thus you need to modify your loop as follows:

 

Totalvol = FirstDate = Firstdate2 = 0; //Initialize arrays before using in a loop.

for (j = 2; j < m; j++)

{

 Totalvol[j] = Totalvol[j] + ValueWhen(((TimeNum()==093000) ),V[j],j);

 FirstDate[j] = ValueWhen(((TimeNum()==093000) ),DateNum(),j);

 Firstdate2[j] = ValueWhen(DateNum()!= Ref(DateNum(),-1),DateNum(),j);

}

 

Also, ValueWhen requires an array and you can't use arrays in a loop. Plus DateNum() may be a problem since it too is an array.

 

This can probably be written without loops:

 

m = 5; d = 22;

Totalvol = IIf(TimeNum() == 093500,Sum(V,d)/d,0); //Solution is not finished…

FirstDate = Ref(DateNum(),m);

 

What are you trying to accomplish with Firstdate2? Your loop is only 22 bars long. If you have minute data it will only cycle through 22 minutes, not 22 days. I think you need to use While or similar loop until you accumulate 22 days of data. You also need to average the daily totals which is not happening.

 

I hope this gives you some direction! I only have a daily database so I can't do any testing.

--

Terry

-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf Of fox97us
Sent: Sunday, December 25, 2005 02:19
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] help---day counter (intraday avg vol) question

 

Hello,

 

  I have some intraday data. Try to get the avg vol from 9;30-9:35am

over one month.

 

 

my code :

 

m=22; // 22 trading days are aound 30 calendar days

 

for (j = 2; j <m; j++)

{Totalvol=Totalvol+ValueWhen(((TimeNum()==093000) ),V,j);

 FirstDate=ValueWhen(((TimeNum()==093000) ),DateNum(),j);

 Firstdate2=ValueWhen(DateNum()!= Ref(DateNum(),-1),DateNum(),j);

}

 

AddColumn(Firstdate,"Firstdate",1.0);

AddColumn(FirstDate2,"Firstdate2",1.0);

 

 

If firstdate2>firstdate, it means there are days there are no trades

between 9;30-9;35am.

 

 

i like to know how many trading days there are from the fristdate to

current date.

 

 

So i wrote

 

Timefromset(indaily);

n=0;

n=barssince(datenum()==fristdate);

 

TimeFrameRestore ();

 

TimeFrameSet (in5Minute);

 

 

However, it doesn't work. if i replace the fristdate with the value

of first date (eg 1051111), it will work. Although the value of

firstdate is a number at each point(I can see it by AddColumn

(Firstdate,"Firstdate",1.0);) , the AFL treats firstdate as an array.

I guess that's the reason why it doesn't work.

 

 

Lots of functions of AFL (like if, for, barssince...) don't accept

arrays as parameters. It's really painful for me to write codes.

 

Any one can help? Thanks a lot.

 

 

william

 

 

 

 

 

 

 

 

------------------------ Yahoo! Groups Sponsor --------------------~-->

Try Online Currency Trading with GFT. Free 50K Demo. Trade

24 Hours. Commission-Free.

http://us.click.yahoo.com/RvFikB/9M2KAA/U1CZAA/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/

 

 

 



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