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

Re: [amibroker] Re: Help in AFL



PureBytes Links

Trading Reference Links

Joe
One question concerning your code.
Why do you write
Count = Close - Close;
intead of
Count = 0; ??

Bernard

Joe Landry a écrit :
Berrnard - I've added a bit to your and Johan's script and I've
 run this routine below on many different watchlists, but it fails(gives zeros)
when the watchlist has empty tickers, i.e. tickers with empty price arrays.
I traced almost every variable in the little routine.  One enhancement would be
to use the IsEmpty function to process or count only the valid(filled) price arrays.
 
IIf(IsEmpty(f), 0, 1);  
       
The way to run this is
Make sure all your tickers have valid arrays in the watchlist you select.
Using the parameters pick a watchlist number and a lookback period.
1) Place a long lived array in the window for current issue - an index, IBM, or other symbol with 3-5K daily bars.
2) under filter select current symbol
3) under range put as many days as you want to list under the explore function 
4) add to composite will generate a curve for you
5) Hit scan to generate ATC, or explore to see what filters out
6) Go to Debug view to see what's working and what's not.
 
Hope this helps
JOE
 
 

// Set the parameters

listnum = Param("Watch List", 1, 0, 63, 1);

lookback = Param("MA Period", 5, 5, 200, 1);

// Set an array of nulls

nbcount = Close-Close;

Count = Close-Close;

Liste = CategoryGetSymbols( categoryWatchlist,Listnum);

for( i = 0; ( Sym = StrExtract( Liste, i ) ) != ""; i++ )

{

f = Foreign( Sym, "C" );

_TRACE("Ticker " + SYm);

MMA = MA(f, Lookback); logic = f>mma;

_TRACE("MAvg "+ MMA+ " Close "+f+" Logic "+logic);

// Need to test here to see if ticker has any data

nbcount = nbcount + IIf(f > MMA,1,0);

Count = Count + 1;

_TRACE("Count "+Count+" nbcount "+nbcount);

}

Buy=Sell = 0;

AddToComposite(nbcount,"~NBTest","X");

Filter =1;

AddColumn(NBCount,"NB");

AddColumn(Count,"Count");

 
----- Original Message -----
From: Joe Landry
Sent: Sunday, July 03, 2005 9:21 AM
Subject: Re: [amibroker] Re: Help in AFL

On TRACE, I believe if you put the trace statement inside the loop, you should get
a trace statement output for each iteration. From that you can see if your logic is working
as it should, you can detect the issues that meet the criteria   Close>MA(C,20) and also
 
 
JOE
----- Original Message -----
Sent: Sunday, July 03, 2005 4:26 AM
Subject: Re: [amibroker] Re: Help in AFL

Johan
Yes Nb was initialzed before the loop but with Nb=0.
Yes the wtachlist is populated.
But I still have a problem with Nb since it is always 0.
Nb is the number of stocks having their Close higher than MA(20) so it should be an array.
So I have modified my code with nb=[0]
But it still don'tworks.
How can I check the array Nb ?
I have tried with _TRACE but it only give one value.

Thanks for your help

Berrnard
 

johsun a écrit :
Bernard,

Two things,

1. The code will give an error if you don't initialize nb. I assume
you're doing that outside the loop so it doesn't get reset to zero
on each iteration...

2. Is watchlist 0 populated?

This works on my computer:


nb = 0;
Liste = CategoryGetSymbols( categoryWatchlist, 0 );
for( i = 0; ( Sym = StrExtract( Liste, i ) ) != ""; i++ )
{
f = Foreign( Sym, "C" );
MMA = MA(f, 20);
nb = nb + (f> MMA);
}

Johan


--- In amibroker@xxxxxxxxxxxxxxx, Bernard Bourée <bernard@xxxx>
wrote:
> I want to build an operator calculated as being the number of
stocks in
> a given WatchList having their Close higher than their MA on 20
days
> My code always return nb=0
>
> Liste = CategoryGetSymbols( categoryWatchlist, 0 );
>     for( i = 0; ( Sym = StrExtract( Liste, i ) ) != ""; i++ )
>    {
>           f = Foreign( Sym, "C" );
>          MMA = MA(f, 20);
>         nb = nb + (f> MMA);
>      }
>
> Thanks for your help
>
> --
> Bernard Bourée
> bernard@xxxx




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




-- 
Bernard Bourée
bernard@xxxxxxxxxx
Mob: +33 6 09 11 05 91 


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





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
Investment management software Investment property software Investment software
Investment tracking software Return on investment software Stock investment software


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




-- 
Bernard Bourée
bernard@xxxxxxxxxx
Mob: +33 6 09 11 05 91 


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