# Positon values for ROC

Hello forum,

I have been trying to do this type of positioning in a system for some time but I can not achieve it.

I have a list in a watchlist with 9 ETF, including TLT.

-If there are 4 assets of the list that have an ROC(Close,6) larger than the ROC (close,6) of TLT, those 4 are bought whit 25% of the capital for each one.

-If there are 3 assets of the list that have an ROC(Close,6) larger than the ROC (close,6) of TLT, those 3 are bought whit 25% of the capital for each one and 25% of the capital for TLT.

-If there are 2 assets of the list that have an ROC(Close,6) larger than the ROC (close,6) of TLT, those 2 are bought whit 25% of the capital for each one and 50% of the capital for TLT.

-If there are 1 asset of the list that have an ROC(Close,6) larger than the ROC (close,6) of TLT, these 1 are bought whit 25% of the capital for each one and 75% of the capital for TLT.

-If there are 0 assets of the list that have an ROC(Close,6) larger than the ROC (close,6) of TLT, TLT is bought with 100% of the capital.

Could someone give me a solution to program it? I have tried it in many ways and I do not do it well.

You did not address the cases where there are 5, 6, 7, or 8 assets with ROC greater than the ROC of TLT, so no one can give you a complete solution. However, there are at least two ways for you to solve this:

1. Use StaticVarGenerateRanks() to rank the ROC(6) values of all symbols, and use the ranks to determine the position sizing
2. Write a Custom Backtest and manipulate the position size before entering trades.