I'm unable to get this formula working quite the way I want. Surely there is no need for sacrifice and there is knowledge and betterment to be gained here.
I'm trying to create a watchlist column for the top% gainers on the day. With the column being sortable in ascending/descending as percent gained, displaying as lets say 63% with no decimal (not as 63.0%) the percent sign at the end (not in the beginning like %63) , and the text in color in green, yellow, or red.
Basically trying to imitate the default built in mark% change or change % column but with custom colors but I keep running into problems.
If I remove the percent from the end [AddLabel(yes, z + "%");] it works and the column is sortable but there is a decimal and .0 at the end displays as 63.0 in color.
If I add the percent at the end, the numbers displays like I want displays as 63% but I lose the color and ability to sort the column (it will just sort randomly not ascending/descending) if I put the percent sign before as %63 i can't add color.
Surely, there is a way,
Here is what I am working with
def AP = AggregationPeriod.DAY;
def y = close(period = AP)[1];
def x = Round(100*((close/y)-1),0);
plot z=x;
z.assignValueColor(if z >= 100 then Color.GREEN else if z >= 50 and z < 100 then Color.YELLOW else if z >= 10 and z < 50 then Color.ORANGE else Color.RED);
AddLabel(yes, z + "%");
I'm trying to create a watchlist column for the top% gainers on the day. With the column being sortable in ascending/descending as percent gained, displaying as lets say 63% with no decimal (not as 63.0%) the percent sign at the end (not in the beginning like %63) , and the text in color in green, yellow, or red.
Basically trying to imitate the default built in mark% change or change % column but with custom colors but I keep running into problems.
If I remove the percent from the end [AddLabel(yes, z + "%");] it works and the column is sortable but there is a decimal and .0 at the end displays as 63.0 in color.
If I add the percent at the end, the numbers displays like I want displays as 63% but I lose the color and ability to sort the column (it will just sort randomly not ascending/descending) if I put the percent sign before as %63 i can't add color.
Surely, there is a way,
Here is what I am working with
def AP = AggregationPeriod.DAY;
def y = close(period = AP)[1];
def x = Round(100*((close/y)-1),0);
plot z=x;
z.assignValueColor(if z >= 100 then Color.GREEN else if z >= 50 and z < 100 then Color.YELLOW else if z >= 10 and z < 50 then Color.ORANGE else Color.RED);
AddLabel(yes, z + "%");