You are overwriting the variable index with the 2nd line so the first is forgotten.
You could try using a loopp for this or combine inot one function like this

index=IIf( Year() == 2005 AND Month() ==  6 AND Day()>=17 AND Day()<24,1, IIf( Year() == 2005 AND Month() ==  6 AND Day()>=24,2,-1));

as an aside you could save yourself a lot of typing by using datenum()
eg
di = datenum();
index=IIf( di>=1050617 and di<1050624, 1, IIf( di>=1050624, 2, -1 ));


--
Cheers
Graham
AB-Write >< Professional AFL Writing Service
Yes, I write AFL code to your requirements
http://e-wire.net.au/~eb_kavan/ab_write.htm


On 17/09/06, ninkiga <[EMAIL PROTECTED]> wrote:
Hello. I want to do backtesting with a system that selects stocks from
a particular watchlist depending on the date, but I cannot get it to
work properly. Here's the pertinent part of my code:

index=IIf( Year() == 2005 AND Month() ==  6 AND Day()>=17 AND
Day()<24,1,-1);

index=IIf( Year() == 2005 AND Month() ==  6 AND Day()>=24,2,-1);

Buy = index > 0 and InWatchList(index);

So if the date is between 2005-6-17 and 2005-6-24, index should be 1,
otherwise -1. And if the date is on or after 2005-6-24, index should
be 2, otherwise -1.

The problem is that I get the error that the fucntion expects a
different argument type. The error goes away if I use LastValue for index:

Buy = index > 0 and InWatchList(LastValue(index));

However, the above seems to result in only stocks being selected from
Watchlist(2), and never Watchlist(1).

How do I correct this? Thanks in advance.








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/

<*> 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: [EMAIL PROTECTED]
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
     [EMAIL PROTECTED]

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






SPONSORED LINKS
Software support Small business finance Business finance online
Business finance training Business finance course

Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___

Reply via email to