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

Re: [amibroker] InWatchList help



PureBytes Links

Trading Reference Links




HB
I believe the problem is that the function 
InWatchlist( ) does not accept an array as arguments.  A solution is to 
specify array elements.
 <FONT 
color=#008000 size=1>
<FONT color=#000000 
size=2>///////////////////////////////////////////////////////////////////// 

// returns 1 if Ticker in Given watchlist on 
specified date //
<FONT color=#000000 
size=2>//////////////////////////////////////////////////////////////////// 

StartBar = LastValue( <FONT 
color=#0000ff>ValueWhen( Status(<FONT 
color=#ff00ff>"firstbarinrange"), BarIndex() ) 
);
FinishBar = LastValue( <FONT 
color=#0000ff>ValueWhen( Status(<FONT 
color=#ff00ff>"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.
 
<FONT 
color=#000000>///////////////////////////////////////////////////////////////////// 

// returns 1 if Ticker in Given watchlist on 
specified date //
<FONT 
color=#000000>//////////////////////////////////////////////////////////////////// 

StartBar = LastValue( <FONT 
color=#0000ff>ValueWhen( Status(<FONT 
color=#ff00ff>"firstbarinrange"), BarIndex() ) 
);
FinishBar = LastValue( <FONT 
color=#0000ff>ValueWhen( Status(<FONT 
color=#ff00ff>"lastbarinrange"), BarIndex() ) 
); 
today = DateNum();
WL1 = 1; // first 
period <FONT 
color=#008000>watchlist 
WL2 = 2; //<FONT 
face="Courier New" color=#008000> second period watchlist
WLempty = 56; //<FONT 
face="Courier New" color=#008000> specify an empty watchlist
i = StartBar;
while (i <= FinishBar)
{
    wlnum[i] =     
IIf(today[i] >=<FONT 
color=#ff00ff>1000101 AND today[i] <=<FONT 
color=#ff00ff>1000630, WL1,
        
                
IIf(today[i] >=1000701 AND today[i] 
<=1001231, <FONT 
face="Courier New">WL2, WLempty));
    inWL[i] = <FONT 
color=#0000ff>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
 
 
<FONT color=#000000 
size=2>////////////////////////////////////////////////////////////////////////////////////////////////
// ASX300/ASX200 returns 1 if Ticker in 
ASX300/ASX200 in given month. (Range 2000 on). //
<FONT color=#000000 
size=2>////////////////////////////////////////////////////////////////////////////////////////////////
StartBar = LastValue( <FONT 
color=#0000ff>ValueWhen( Status(<FONT 
color=#ff00ff>"firstbarinrange"), BarIndex() ) 
);
FinishBar = LastValue( <FONT 
color=#0000ff>ValueWhen( Status(<FONT 
color=#ff00ff>"lastbarinrange"), BarIndex() ) 
); 
Yr = Year();
Mth = Month();
Ticker = Name();
i = StartBar;
while (i <= FinishBar)
{
WatchlistNum[i] =     <FONT 
color=#0000ff>IIf(Yr[i] ==2000, <FONT 
color=#0000ff>IIf(Mth[i] <7, <FONT 
color=#ff00ff>30,31),
        
                
        IIf(Yr[i] ==<FONT 
color=#ff00ff>2001, IIf(Mth[i] <<FONT 
color=#ff00ff>7, 32,<FONT 
color=#ff00ff>33),
        
                
        IIf(Yr[i] ==<FONT 
color=#ff00ff>2002, IIf(Mth[i] <<FONT 
color=#ff00ff>7, 34,<FONT 
color=#ff00ff>35),
        
                
        IIf(Yr[i] ==<FONT 
color=#ff00ff>2003, IIf(Mth[i] <<FONT 
color=#ff00ff>7, 36,<FONT 
color=#ff00ff>37),39))));
    InASX300[i] = <FONT face="Courier New" 
color=#0000ff>InWatchList( 
WatchlistNum[i] );
WatchlistNum[i] = <FONT 
color=#0000ff>    <FONT 
color=#0000ff>IIf(Yr[i] ==2000, <FONT 
color=#0000ff>IIf(Mth[i] <7, <FONT 
color=#ff00ff>40,41),
        
                
        IIf(Yr[i] ==<FONT 
color=#ff00ff>2001, IIf(Mth[i] <<FONT 
color=#ff00ff>7, 42,<FONT 
color=#ff00ff>43),
        
                
        IIf(Yr[i] ==<FONT 
color=#ff00ff>2002, IIf(Mth[i] <<FONT 
color=#ff00ff>7, 44,<FONT 
color=#ff00ff>45),
        
                
        IIf(Yr[i] ==<FONT 
color=#ff00ff>2003, IIf(Mth[i] <<FONT 
color=#ff00ff>7, 46,<FONT 
color=#ff00ff>47),49))));
    InASX200[i] = <FONT face="Courier New" 
color=#0000ff>InWatchList( 
WatchlistNum[i] );
i = i + 1;
}
Filter = InASX300;
AddColumn(InASX300,"in 
ASX300");
AddColumn(InASX200,"on ASX200");
 
 
----- Original Message ----- 
<BLOCKQUOTE 
>
  <DIV 
  >From: 
  HB 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">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.
   
  <FONT face=Arial 
  size=2>//////////////////////////////////////
   
  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;
   
  <FONT face=Arial 
  size=2>AddColumn(InWatchList(wlnum),"inWL",1.0);
  
   
  <FONT face=Arial 
  size=2>//////////////////////////////////////
   
  Thanks,
  HBSend BUG REPORTS to 
  bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  
  
  Yahoo! Groups Links
  
    To visit your group on the web, go to:<A 
    href="">http://groups.yahoo.com/group/amibroker/  

    To unsubscribe from this group, send an email to:<A 
    href="">amibroker-unsubscribe@xxxxxxxxxxxxxxx  

    Your use of Yahoo! Groups is subject to the <A 
    href="">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 the Yahoo! Terms of Service.