♥ 0 |
Hello Pete,
I had a question how do we round values 2 decimal places in the display labels. For example in the volume code below .
def Pre = if SecondsFromTime(100) > 0 and AddLabel(yes, “Premarket Volume: ” + PreMarketVol, if PreMarketVol > 2510000 then Color.RED else Color.white);
Marked as spam
|
Private answer
Rounding values in a chart label. Already been asked and answered here: https://www.hahn-tech.com/ans/output-value-only-to-2-decimal-places/
The AddLabel() function takes three parameters. Get the full details here: https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AddLabel.html ALWAYS begin with the most basic code. Then add to it once you get the most basic version working. From the previous post I linked above, we have this as the example:
Ok,
Once you get this working you can then add the if/then/else statement to dynamically set the color of the label. Do this by replacing "Color.MAGENTA" with your if/then/else statement. From your original code, that color assignment is done using the following snippet:
After we use that to replace Color.MAGENTA we end up with the following:
Now that you see how this is done, I'll let you complete the other label in your code, which contains the exact same errors as this one. Marked as spam
|
Please log in to post questions.