Not exactly sure what you want, but here is an addchartbubble with the 123 converted to a stacked 123.Example:
Convert a Number to String:
123 to "1" + "/n" + "2" + "/n"+"3"+"/n"
Ruby:plot Data = expaverage(close,8) crosses close; addchartBubble(data,high,"1\n2\n3", color = Color.WHITE);
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Here is another method that creates a label with the hopefully any 3 digit number you input.Not exactly sure what you want, but here is an addchartbubble with the 123 converted to a stacked 123.
Ruby:input data = 592; def digit1 = Round(Floor(data / 100), 0); def digit2 = Floor((data - Round(Floor(data / 100), 0) * 100) / 10); def digit3 = (data - Round(Floor(data / 100), 0) * 100) / 10 % 1 * 10; addlabel(1,digit1+"/n"+digit2+"/n"+digit3+"/n",color.white);
Works perfectly thanks. Is there a way to dynamically convert a double to a string and then process? For example if the close = 4268.32 then I need to know that it has 4 digits to process instead of 3. Also why is it I cannot assign string to AsText. Input string1 = AsText(....) doesn't work.Here is another method that creates a label with the hopefully any 3 digit number you input.
TOS's string functionality is limited.Works perfectly thanks. Is there a way to dynamically convert a double to a string and then process? For example if the close = 4268.32 then I need to know that it has 4 digits to process instead of 3. Also why is it I cannot assign string to AsText. Input string1 = AsText(....) doesn't work.
Ruby:input x = 1; AddLabel(1, if x == 1 then "Hello" else "Goodbye", Color.WHITE); input c = 4268.32; AddLabel(1, if Between(c / 1000, 1, 9) then "4 digits" else "Not 4 digits" , Color.WHITE);
Thanks a lot. Perfect example for me to extend and make it work.TOS's string functionality is limited.
You cannot input string1 = AsText(...). Look up that function in the education tab for a further explanation of its use.
You can input text as part of a switch/case scenario, for example, input PivotType = {Woodies, Floor, default Camarilla};.
The following code has an example of how to use an input to create text in a label.
The other example helps to determine if the input 'c' value is exactly a 4 digit number.
thanks for sharing , sleepyz. i forget to use between.TOS's string functionality is limited.
You cannot input string1 = AsText(...). Look up that function in the education tab for a further explanation of its use.
You can input text as part of a switch/case scenario, for example, input PivotType = {Woodies, Floor, default Camarilla};.
The following code has an example of how to use an input to create text in a label.
The other example helps to determine if the input 'c' value is exactly a 4 digit number.
#
input quantity_of_digits = 4;
def powernum = (quantity_of_digits-1);
def c = close;
def p = power(10, powernum);
#addlabel(1, p, color.magenta);
#AddLabel(1, if Between(c / 1000, 1, 9) then "4 digits" else "Not 4 digits" , Color.WHITE);
AddLabel(1, if Between(c / p, 1, 9) then (quantity_of_digits + " digits") else ("Not " + quantity_of_digits + " digits") , Color.WHITE);
#
## determine quantity of digits in price
def digits = if Between(c / 1, 1, 9) then 1
else if Between(c / 10, 1, 9) then 2
else if Between(c / 100, 1, 9) then 3
else if Between(c / 1000, 1, 9) then 4
else if Between(c / 10000, 1, 9) then 5
else 0;
addlabel(1, "digits in price " + digits, color.yellow);
Start a new thread and receive assistance from our community.
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.
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.