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

Re: [amibroker] InWatchList help



PureBytes Links

Trading Reference Links




Thanks Graham.  That was it !
 
I ended up using the following code:
 

//////////////////////////////
 
// Date conditionsZeroKH1 = 
IIf(today>=1000101 AND today <=1000630, 7,0);ZeroKH2 = 
IIf(today>=1000701 AND today <=1001231, 9,0);OneKH1 = 
IIf(today>=1010101 AND today <=1010630, 11,0);OneKH2 = 
IIf(today>=1010701 AND today <=1011231, 13,0);TwoKH1 = 
IIf(today>=1020101 AND today <=1020630, 15,0);TwoKH2 = 
IIf(today>=1020701 AND today <=1021231, 17,0);
 
// Watchlist membershipwl7 = InWatchList(7);wl9 = 
InWatchList(9);wl11 = InWatchList(11);wl13 = InWatchList(13);wl15 = 
InWatchList(15);wl17 = InWatchList(17);
 
// Ticker is in right date range and is a member of the right 
watchlistrightWL = (ZeroKH1 AND wl7) OR (ZeroKH2 AND wl9) OR (OneKH1 AND 
wl11) OR (OneKH2 AND wl13) OR (TwoKH1 AND wl15) OR (TwoKH2 AND 
wl17);
 
//////////////////////////////
 
I know the two sets of conditions be combined but I 
spell it out for my own benefit/understanding.
 
HB
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  <A title=gkavanagh@xxxxxxxxxxxxx 
  href="">Graham 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Tuesday, December 16, 2003 9:32 
  PM
  Subject: RE: [amibroker] InWatchList 
  help
  
  you could just use the 
  watchlist numbers and have added conditional statements
   
  cond1 = 
  datenum()>1000101 and datenum()<1000701;
  cond2 = 
  inwatchlist(7);
  cond3 = 
  inwatchlist(9);
  
  Buy = Buyconditions AND<SPAN 
  class=171512702-17122003> ( ( 
  cond1 and<SPAN 
  class=171512702-17122003> cond2 ) or cond3 );<SPAN 
  class=171512702-17122003>//have added or etc as 
  variety
  <FONT 
face=Arial> 
  or if you only have a 
  single watchlist
  <FONT 
face=Arial> 
  
  cond1 = 
  datenum()>1000101 and 
  datenum()<1000701;
  
  Buy = Buyconditions AND InWatchList(<SPAN 
  class=171512702-17122003>7) 
  and cond1;<SPAN 
  class=171512702-17122003> 
  Cheers,Graham<A 
  href="">http://groups.msn.com/asxsharetrading<A 
  href="">http://groups.msn.com/fmsaustralia 
  
  
    
    <FONT 
    face=Tahoma size=2>-----Original Message-----From: HB 
    [mailto:hmab@xxxxxxxxxxxxxx] Sent: Wednesday, 17 December 2003 
    10:13 AMTo: amibroker@xxxxxxxxxxxxxxxSubject: Re: 
    [amibroker] InWatchList help
    Jayson, Graham, & Andrew,
     
    Thanks for your tips.
     
    Let me give me more details as to how I want to 
    use this.  When backtesting, I need to determine, for each bar, if this 
    ticker is part of a certain watch list.  If so, then I will accept 
    the buy signal, otherwise on.
     
    In my code sample, if the current bar is in the 
    first half of year 2000, then tickers need to be in watchlist 7 in order to 
    accept buy signals.  If the current bar is in the second half of year 
    2000, then tickers need to be in watchlist 9 in order to accept buy 
    signals.  
     
    I was hoping to do something like:
     
    Buy = Buyconditions AND 
    InWatchList(wlnum);
     
    So, in this case, is the solution to use 
    Andrew's first code snippet ?  Or is there a simpler way to do this 
    ?
     
    Thanks,
    HB
     
    <BLOCKQUOTE 
    >
      ----- Original Message ----- 
      <DIV 
      >From: 
      <A title=a.perrin@xxxxxxxxxxxxxxx 
      href="">Andrew Perrin 
      To: <A 
      title=amibroker@xxxxxxxxxxxxxxx 
      href="">amibroker@xxxxxxxxxxxxxxx 
      
      Sent: Tuesday, December 16, 2003 8:34 
      PM
      Subject: Re: [amibroker] InWatchList 
      help
      
      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 face=Arial 
      size=2>
      <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"), <FONT 
      color=#0000ff>BarIndex() ) );
      FinishBar = LastValue( <FONT 
      color=#0000ff>ValueWhen( Status(<FONT 
      color=#ff00ff>"lastbarinrange"), <FONT 
      color=#0000ff>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"), <FONT 
      color=#0000ff>BarIndex() ) );
      FinishBar = LastValue( <FONT 
      color=#0000ff>ValueWhen( Status(<FONT 
      color=#ff00ff>"lastbarinrange"), <FONT 
      color=#0000ff>BarIndex() ) ); 
      today = DateNum();
      WL1 = 1; // first 
      period <FONT 
      color=#008000>watchlist 
      WL2 = 2; <FONT 
      color=#008000>// second 
      period watchlist
      WLempty = 56; <FONT 
      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] >=<FONT 
      color=#ff00ff>1000701 AND today[i] <=<FONT 
      color=#ff00ff>1001231, WL2,<FONT 
      face="Courier New"> 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> 
       
      <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"), <FONT 
      color=#0000ff>BarIndex() ) );
      FinishBar = LastValue( <FONT 
      color=#0000ff>ValueWhen( Status(<FONT 
      color=#ff00ff>"lastbarinrange"), <FONT 
      color=#0000ff>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] 
      ==2001, IIf(Mth[i] 
      <7, 32,<FONT 
      color=#ff00ff>33),
              
                  
                  IIf(Yr[i] 
      ==2002, IIf(Mth[i] 
      <7, 34,<FONT 
      color=#ff00ff>35),
              
                  
                  IIf(Yr[i] 
      ==2003, IIf(Mth[i] 
      <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] 
      ==2001, IIf(Mth[i] 
      <7, 42,<FONT 
      color=#ff00ff>43),
              
                  
                  IIf(Yr[i] 
      ==2002, IIf(Mth[i] 
      <7, 44,<FONT 
      color=#ff00ff>45),
              
                  
                  IIf(Yr[i] 
      ==2003, IIf(Mth[i] 
      <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@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@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@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.