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

[amibroker] Re: InWatchList help



PureBytes Links

Trading Reference Links

Example:
Buy1=Cross(StochD(),30);Sell1=Cross(StochD(),80);
Buy=(InWatchList(5) AND DateNum()<1030101 AND Buy1)+(InWatchList(10) 
AND DateNum()>1030101 AND Buy1);
Sell=(InWatchList(5) AND DateNum()<1030101 AND Sell1)+(InWatchList
(10) AND DateNum()>1030101 AND Sell1);
You should scan a set of stocks wider or equal to the sum of WL5+WL10 
stocks.
Dimitris Tsokakis
--- In amibroker@xxxxxxxxxxxxxxx, "HB" <hmab@xxxx> wrote:
> 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
> 
>   ----- Original Message ----- 
>   From: Andrew Perrin 
>   To: 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.
> 
>   //////////////////////////////////////////////////////////////////
/// 
>   // 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 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@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 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 Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

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/