Welcome Features News Download Registration Support FAQ Wish list Links
Advanced stock charting and analysis program

AFL Library

This is read-only version of AFL library entry. Ability to add user formulas and comment is only available from members-only area.

Details:

Formula name: Ranking Ticker WatchList
Author/Uploader: nenapacwanfr - s.carrasset [at] laposte.net
Date/Time added: 2004-12-05 13:54:05
Origin:
Keywords:
Level: basic
Flags: indicator

DISCLAIMER: Most formulas present in AFL on-line library are submitted by the users and are provided here on an "as is" and "as available" basis. AmiBroker.com makes no representations or warranties of any kind to the contents or the operation of material presented here. We do not maintain nor provide technical support for 3rd party formulas.
Description:

/*
returns the Rank of a ticker in a WL for a given indicator
if the ticker is outside the WL the rank is empty
UNFORTUNATELY if the WL contains many tickers the formula is slowwwwww
*/

Formula:


/* 
returns the Rank of a ticker in a WL for a given indicator
if the ticker is outside the WL the rank is empty
UNFORTUNATELY if the WL contains many tickers the formula is slowwwwww
*/

listNum=0 ;//enter watchlist number
list = GetCategorySymbols( categoryWatchlist, listnum );

for( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ )
{
SetForeign(sym);
VarSet("MyInd"+i,MFI(14));// Indicator
/*
VarSet stores the Value of MFI
ticker 0 has its value of MFI stored in MyInd + 0
ticker 1 has its value of MFI stored in MyInf + 1 ...
*/
Rank =1;// Initialize the Rank

for( j = 0; ( item = StrExtract( list, j ) ) != ""; j++ )
{
SetForeign(item);
VarSet("ThisInd"+j,MFI(14));//Indicator
Rank=Rank + IIf( VarGet("MyInd"+i) < VarGet("ThisInd"+j),1,0);
/*
VarGet returns the value of VarSet
Every value of MyInd + i is compared to every Value of ThisInd + j
and the Rank in incremented of + 1 every time the Ind is < to others.
you can also write it
Rank=Rank + IIf( VarGet("MyInd"+i) < MFI(14),1,0);
because of SetForeign
*/
RestorePriceArrays();// to get out the influence of SetForeign
}
VarSet("Rank"+i,Rank);
}

/*
I want to know the Rank when I click on a ticker
I must know the position of the ticker in a WL
this loop can do the job instead of writing
IIf(Name()=="12017", 0, IIf(Name()=="12027", 1, ...
*/
Count=0;
BreakLoop = False;
for( k = 0; NOT(BreakLoop) &&( ticker = StrExtract( list, k ) ) != ""; k++ )
{
if(Name()==ticker)
Breakloop=True;
else
Count=Count+1;
}


//Plot(Count,"",2,1);
Plot(VarGet("Rank"+ Count),"",2,1);

/*
you Can Control the Rank if you Plot the MFI Of every tickers with
list = GetCategorySymbols( categoryWatchlist, listnum ); 

for( i = 0; ( sym = StrExtract( list, i ) ) != ""; i++ ) 
{ 
SetForeign(sym);
Plot(MFI(14) ,sym,i+1,1);
}
*/

Comments:

Mike Mann
mikemann [at] profitscore.com
2006-04-19 17:33:32
I loaded and ran the code on 41 tickers in a watch list. Changed the MFI to ROC(13) in both places (i counter and j counter loops). Then did an exploration showing the ticker, rank and ROC....... ranks and ROC did not match up. Have you found any bugs in the code. I can't get it to make sense. Don't know what I might be missing.


About | Privacy | Terms of Use | Contact information
Copyright © 2001 AMIBROKER.COM