PureBytes Links
Trading Reference Links
|
Sorry that should have been compares to Watchlist 0 outside
specified dates
Andrew
--- In amibroker@xxxxxxxxxxxxxxx, "Andrew Perrin" <a.perrin@xxxx>
wrote:
> HB
> I believe the problem is that the function InWatchlist( ) does not
accept an array as arguments. A solution is to specify array
elements.
>
> ///////////////////////////////////////////////////////////////////
//
> // returns 1 if Ticker in Given watchlist on specified date //
> ///////////////////////////////////////////////////////////////////
/
> StartBar = LastValue( ValueWhen( Status("firstbarinrange"),
BarIndex() ) );
> FinishBar = LastValue( ValueWhen( Status("lastbarinrange"),
BarIndex() ) );
> today = DateNum();
> i = StartBar;
> while (i <= FinishBar)
> {
> ZeroKH1[i] = IIf(today[i]>=1000101 AND today[i] <=1000630, 7,0);
> ZeroKH2[i] = IIf(today[i] >=1000701 AND today[i] <=1001231, 9,0);
> wlnum[i] = ZeroKH1[i] + ZeroKH2[i];
> inWL[i] = InWatchList(wlnum[i]);
> i = i + 1;
> }
> Filter = 1;
> AddColumn(InWL,"inWL",1.0);
>
> This will work, it will however compare ticker to watchlist num 1
outside of the dates specified and will give a true result if
Watchlist 1 does contain ticker.
> Another solution that may overcome this is to use nested IIf
statements.
>
> ///////////////////////////////////////////////////////////////////
//
> // returns 1 if Ticker in Given watchlist on specified date //
> ///////////////////////////////////////////////////////////////////
/
> StartBar = LastValue( ValueWhen( Status("firstbarinrange"),
BarIndex() ) );
> FinishBar = LastValue( ValueWhen( Status("lastbarinrange"),
BarIndex() ) );
> today = DateNum();
> WL1 = 1; // first period watchlist
> WL2 = 2; // second period watchlist
> WLempty = 56; // specify an empty watchlist
> i = StartBar;
> while (i <= FinishBar)
> {
> wlnum[i] = IIf(today[i] >=1000101 AND today[i] <=1000630,
WL1,
> IIf(today[i] >=1000701 AND today[i]
<=1001231, WL2, WLempty));
> inWL[i] = InWatchList(wlnum[i]);
> i = i + 1;
> }
> Filter = 1;
> AddColumn(InWL,"inWL",1.0);
>
> If you are doing something more complex in this area, perhaps the
following AFL might help. Watchlist were set up to reflect the
composition of certain indexes at 6 mth intervals. Tickers were
selected that were part of the index at the start of each six month
period.
>
> Hope this helps, watch those line returns,
>
> Andrew
>
>
> ///////////////////////////////////////////////////////////////////
/////////////////////////////
> // ASX300/ASX200 returns 1 if Ticker in ASX300/ASX200 in given
month. (Range 2000 on). //
> ///////////////////////////////////////////////////////////////////
/////////////////////////////
> StartBar = LastValue( ValueWhen( Status("firstbarinrange"),
BarIndex() ) );
> FinishBar = LastValue( ValueWhen( Status("lastbarinrange"),
BarIndex() ) );
> Yr = Year();
> Mth = Month();
> Ticker = Name();
> i = StartBar;
> while (i <= FinishBar)
> {
> WatchlistNum[i] = IIf(Yr[i] ==2000, IIf(Mth[i] <7, 30,31),
> IIf(Yr[i] ==2001, IIf(Mth[i] <7,
32,33),
> IIf(Yr[i] ==2002, IIf(Mth[i] <7,
34,35),
> IIf(Yr[i] ==2003, IIf(Mth[i] <7,
36,37),39))));
> InASX300[i] = InWatchList( WatchlistNum[i] );
> WatchlistNum[i] = IIf(Yr[i] ==2000, IIf(Mth[i] <7, 40,41),
> IIf(Yr[i] ==2001, IIf(Mth[i] <7,
42,43),
> IIf(Yr[i] ==2002, IIf(Mth[i] <7,
44,45),
> IIf(Yr[i] ==2003, IIf(Mth[i] <7,
46,47),49))));
> InASX200[i] = InWatchList( WatchlistNum[i] );
> i = i + 1;
> }
> Filter = InASX300;
> AddColumn(InASX300,"in ASX300");
> AddColumn(InASX200,"on ASX200");
>
>
> ----- Original Message -----
> From: HB
> To: amibroker@xxxxxxxxxxxxxxx
> Sent: Wednesday, December 17, 2003 6:21 AM
> Subject: [amibroker] InWatchList help
>
>
> Hello,
>
> I'm getting an error with the last line of following code.
Something about a bad argument. Can someone please help.
>
> //////////////////////////////////////
>
> today = DateNum();
>
> ZeroKH1 = IIf(today>=1000101 AND today <=1000630, 7,0);
> ZeroKH2 = IIf(today>=1000701 AND today <=1001231, 9,0);
>
> wlnum = ZeroKH1 + ZeroKH2;
>
> Filter = 1;
>
> AddColumn(InWatchList(wlnum),"inWL",1.0);
>
> //////////////////////////////////////
>
> Thanks,
> HB
>
>
> Send BUG REPORTS to bugs@xxxx
> Send SUGGESTIONS to suggest@xxxx
> -----------------------------------------
> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> --------------------------------------------
> Check group FAQ at:
http://groups.yahoo.com/group/amibroker/files/groupfaq.html
>
>
> Yahoo! Groups Sponsor
> ADVERTISEMENT
>
>
>
>
>
> -------------------------------------------------------------------
-----------
> Yahoo! Groups Links
>
> a.. To visit your group on the web, go to:
> http://groups.yahoo.com/group/amibroker/
>
> b.. To unsubscribe from this group, send an email to:
> amibroker-unsubscribe@xxxxxxxxxxxxxxx
>
> c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms
of Service.
Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.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/
|