Perhaps you can use the function below, where I've used RSI and ROC
as example criteria to cross-rank a list:
function XSecRanksVarSet(List, Crit, Lookback)
{
global PercRank;
if (Crit==1) CurrInd=RSI(Lookback); else if (Crit==2)
CurrInd=ROC(C,Lookback);
for (j = 0;( Naam = StrExtract( List, j ) ) != "" ; j++ )
{
SetForeign(Naam, True);
if (Crit==1) ChoiceVar=RSI(Lookback);
else if (Crit==2) ChoiceVar=ROC(C,Lookback);
VarSet("PeerInd"+j, Nz(ChoiceVar,LastValue(MA
(ChoiceVar,Lookback))));
RestorePriceArrays();// to get out the influence of
SetForeign
}
Rank=1;
for (i=0;( Naam2 = StrExtract( List, i ) ) != "" ; i++ )
{
if (Name()!=Naam2) Rank=Rank + IIf( CurrInd >
VarGet("PeerInd"+i),1,0);
//if (RankCrit==0) Rank=Rank + IIf( CurrInd >
VarGet("PeerInd"+i),1,0);
//else Rank=Rank + IIf( CurrInd < VarGet
("PeerInd"+i),1,0);
}
PercRank=Rank/i;
return Rank;
}
In your rotational code, you then simply adjust your PositionScore by:
InOut = iif(Rank>Ref(Rank,-1),1,0);
PositionScore = InOut* Your Positionscore;// If PositionScore = 0, no
position.
Just some guidance, hope it helps.
PS
"Next time, you contribute to the group?"
--- In [email protected], "anand_huprikar" <[EMAIL PROTECTED]>
wrote:
>
> I want to include a condition that the rank today has to be better
> (lower)than rank yesterday before taking a position in the
> rotational trading system.Can this be done in the AFL?
> Thanks
>