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.