Convert number in label to short form


Category:
0
0

Hi Pete,
I have a label of the total volume for the day, which displays it in unnecessarily long form, e.g., 315,774,788. This takes up too much space as a label. I would like to convert the number in the label to a short form (based on millions, with one decimal place), for example; 315.7M

Here is the simple code example;

def volumeDollars = Round(volume, 0);
def newDay = GetDay() <> GetDay()[1];
rec todaysVolumeDollars = if newDay then volumeDollars else todaysVolumeDollars[1] + volumeDollars;
AddLabel(yes, Concat(“Vol: “, todaysVolumeDollars), Color.GREEN);

Marked as spam
Posted by (Questions: 7, Answers: 12)
Asked on October 13, 2022 10:31 am
38 views
0
Private answer

There are no built-in language tools for automatically adapting values as you describe. The platform has it's own methods which are baked into the platform itself. No such tools are available to custom chart studies.

The only thing we can do is to convert the values manually. Such as dividing a specific value by 1 million. But then you end up with problems when the original value is less than 1 million. There is no blanket solution for this and each case must be managed with a custom solution.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on October 13, 2022 11:17 am