# Close Prices in Ascending Order

#### Vamsy

##### New member
Can Close Prices of last 5 Days Sorted in Ascending Order in TOS...?

Example
: Close Prices of X in Last 5 Days are 20,15,18,22,10.

Can these Values Sorted in Ascending Order and Added to Labels...?

Result Expected in TOS Labels : 10,15,18,20,22

Solution
Mentioned threads have sorted/ assigned ranking in Descending order.

Can the Close Values Sorted in Ascending Order…?

? they are in ascending order.
1 is assigned to the lowest number and 10 to the highest of 10 numbers. and those in between are numbered accordingly.

i am away now , so i'm typing this on my cell. in a few days i can verify this.

copy the code from here
post4

paste it in as a new study
set chart to day

change this to 5
input qty = 10;

Code:
``````def dat1 = if bn >= rngbar1 and rank3 == 1 then data else dat1[1];
def dat2 = if bn >= rngbar1 and rank3 == 2 then data else dat2[1];
def dat3 = if bn >= rngbar1 and rank3...``````
Can Close Prices of last 5 Days Sorted in Ascending Order in TOS...?

Example
: Close Prices of X in Last 5 Days are 20,15,18,22,10.

Can these Values Sorted in Ascending Order and Added to Labels...?

Result Expected in TOS Labels : 10,15,18,20,22

it is possible to assign a ranking number to some values in a variable.
then you could look for each rank number , find an offset, and read the desired data.

Mentioned threads have sorted/ assigned ranking in Descending order.

Can the Close Values Sorted in Ascending Order…?

? they are in ascending order.
1 is assigned to the lowest number and 10 to the highest of 10 numbers. and those in between are numbered accordingly.

i am away now , so i'm typing this on my cell. in a few days i can verify this.

copy the code from here
post4

paste it in as a new study
set chart to day

change this to 5
input qty = 10;

Code:
``````def dat1 = if bn >= rngbar1 and rank3 == 1 then data else dat1[1];
def dat2 = if bn >= rngbar1 and rank3 == 2 then data else dat2[1];
def dat3 = if bn >= rngbar1 and rank3 == 3 then data else dat3[1];
def dat4 = if bn >= rngbar1 and rank3 == 4 then data else dat4[1];
def dat5 = if bn >= rngbar1 and rank3 == 5 then data else dat5[1];

? they are in ascending order.
1 is assigned to the lowest number and 10 to the highest of 10 numbers. and those in between are numbered accordingly.

i am away now , so i'm typing this on my cell. in a few days i can verify this.

copy the code from here
post4

paste it in as a new study
set chart to day

change this to 5
input qty = 10;

Code:
``````def dat1 = if bn >= rngbar1 and rank3 == 1 then data else dat1[1];
def dat2 = if bn >= rngbar1 and rank3 == 2 then data else dat2[1];
def dat3 = if bn >= rngbar1 and rank3 == 3 then data else dat3[1];
def dat4 = if bn >= rngbar1 and rank3 == 4 then data else dat4[1];
def dat5 = if bn >= rngbar1 and rank3 == 5 then data else dat5[1];

How to do it for Every 5 Day Rolling...?

Ranking Logic is taking the Quantity as a Base Reference and Computing the Ranking Values of Given Quantity.

Do You have any reference Script For Rolling Range of Quantity....??

87k+ Posts
113 Online

## The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
• Exclusive indicators
• Proven strategies & setups
• Private Discord community
• Exclusive members-only content
• 1 full year of unlimited support

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?