Optimize rank selected in rotational strategy

I am attempting to test which rank actually performs best in my monthly rotational strategy. The position score will default to the highest score or "best rank" so to speak. I can optimize worst rank held but that does not accomplish the goal. I want to compare the rank selections individually .

My goal is to run an optimization showing the performance of the system in a 5 year period where it tests each rank separately. So the fist line would show the back test selecting rank 1 every month, the second line would show the system selecting rank 2 every month all the way down to 504 since I am testing on the S&P.

Here is the code for the optimization of worst rank held which does work but it is not what I am trying to accomplish.

SetBacktestMode( backtestRotational );




SetPositionSize( 99.5, spsPercentOfEquity );

Score= (ROC(Close, 1) +ROC(Close, 3) +ROC(Close,6))/3  ;

PositionScore = Score;

variable = Optimize("WorstRankHeld",1 , 1, 504, 1 );
SetOption("WorstRankHeld", variable ); // YOU HAVE TO USE the variable!Z

I wanted to point you to:

But then found you actualy started that thread yourself...

Why not ask your question there and start a new one ?

Most people don't appreciate it if new threads are made for every new question :wink:

I actualy thought your answer was allready there... but apperantly you missed it... I unfortunatly do not know.

1 Like

I tried to post to that thread but it would not let me.

That is strange... lets hope someone will help you here then. I unfortunatly am not able to, my knowledge of AFL is not good enough.

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.