Add Text bubble on Lower Study


Category:
0
0

Is there any command (or work around) to put a small text on the lower study? I have an MTF study which plots four lines for four timeframes. I would like to display a small text on each line to indicate  the related timeframe (something similar to the way TOS displays % and Price on the Fibonacci level lines)

 

Thanks

‘Arun

Marked as spam
Posted by (Questions: 11, Answers: 16)
Asked on March 21, 2018 9:19 pm
2870 views
0
Trying to put a letter in the ChartBubble to indicate the time period the plot represents, but cant get rid of syntax errors in my code:Tried two different ways without luck. Can anyone pls help? This code gives me invalid statement error: if Period3== AggregationPeriod.DAY then AddChartBubble (IsNan(close())and (!IsNan(close()[1])), 1, “D”, color.YELLOW, yes) else AddChartBubble (IsNan(close())and (!IsNan(close()[1])), 1, “M”, color.YELLOW, yes); #def x= if Period3== AggregationPeriod.DAY then “D” else “”; This gives Incompatible parameters error. def bubbleVar= if Period3== AggregationPeriod.DAY then “D” else ” if Period3== AggregationPeriod.WEEK then “D” else “M”; Thanks Arun
( at March 24, 2018 9:00 am)
0

Couple things. The AddChartBubble statements always stands alone. It cannot be invoked from within an If/Then statement. All variables in Thinkscript must be in the form of numeric values. They can never be string (text) values.

From what I see you are trying to do I suggest this as the best option:

AddChartBubble(IsNaN(close) and !IsNaN(close[1]), 1, if Period3 == AggregationPeriod.DAY then “D” else “M”, Color.YELLOW, yes);

( at March 24, 2018 10:52 am)
0

Thank you.

( at March 24, 2018 11:50 pm)
0
Private answer

Sorry we cannot print “small text” on any plots in Thinkorswim. The only way to print text labels on a chart plot is to use the AddChartBubble() function. You can read about it here: http://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Look—Feel/AddChartBubble.html

Since they tend to get in the way of price action and make for a sloppy looking chart, it’s helpful to have a technique for turning them on and off through the user inputs. I think this post will give you the basics to enable you to implement it: https://www.hahn-tech.com/ans/alert-hi-low-v2/

TheAddChartBubble() function takes a true/false variable as it’s first argument. This tells the code on which bar(s) to place the bubbles. If set to ‘yes’, a chart bubble will be placed on every bar. If you want to plot the chart bubble on ONLY the last bar, you can use this: !IsNaN(close) and IsNaN(close[-1])

 

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on March 22, 2018 8:15 am
0

Arun, you posted your follow up question as a new answer instead of as a comment. So it has been deleted. Unless you are providing a new answer to the question, do not use the “Post your Answer” box at the bottom of the thread. Instead, use the comment link. Just like I have done here.

( at March 23, 2018 8:36 am)
0

The content of Arun’s follow up question was this:

“It seems AddBubble needs a PriceLocation. My Lower Study (I mean my indicator displayed under the chart) does not plot any price info. It is merely a “plot 0” which plots a dot in green or red color based on certain conditions. Any other suggestions if this command can’t be used in such a case or is there any work around?”

Did you try what I suggested in the very last line of my answer? That is the solution to your particular case. Here it is again:

“If you want to plot the chart bubble on ONLY the last bar, you can use this: !IsNaN(close) and IsNaN(close[-1])”

( at March 23, 2018 8:38 am)
0

From the list of required arguments for AddBubble, I thought only close,high etc are required for the second argument. Did not realize 0 works as a valid argument. And thanks for the !IsNaN(close) and IsNaN(close[-1]) hint.
Tried reversing the IsNan(close) and !IsNan(close) to see if the bubble gets printed on the first dot. Wonder why that does not work but close[-1] is Valid.

( at March 23, 2018 2:38 pm)
0

Yes, that only works for plotting on the last bar of the chart. There is a way to plot on the first bar of the chart. But that is rarely the first bar in the viewable space of the chart. I am taking this to mean you want to plot the labels at the far left of the viewable chart space. We cannot access the viewable space, so we cannot get there with available tools.

( at March 23, 2018 2:49 pm)
0

Great point about first bar v first view-able bar, so though I found barnumber() command after posting my comment, it won’t really help.

( at March 23, 2018 8:06 pm)
0
On the related topic, I have an additional question: I have some code as follows:(This iso n a daily chart for 1 month, has 21 Bars and if I include the right expansion area., then total 45 bars. declare lower; plot line3= 3; Plot Line1=1; plot Line = 0; def closedBar = if IsNaN(close())then double.Nan else barNumber() ; def TotBars = HighestAll(BarNumber()); AddLabel( yes, Concat(closedBar, TotBars), Color.RED ); AddChartBubble( barNumber() ==closedBar/ 2 or barNumber() == ((closedBar / 2) + .5), 1, concat(barnumber(), TotBars ) , Color.YELLOW, yes); AddChartBubble( barNumber() == TotBars / 2 or barNumber() == ((TotBars / 2) + .5), 0, Concat(barnumber(), TotBars) , Color.YELLOW, yes); The output in AddLabel was 21and 45 (as expected). On the Plot 1, instead of printing the bubble at bar#11 (barNumber() ==closedBar/ 2 +.5), It prints at 1. The bubble display was 1 for barnumber() and 45 for Total bars incl expansion. However on line 0, the bubble was at the mid point and the bubble output for barnumber() was 23 and total bars incl expansion 45. Why was the midpoint not working on Plot1? Thanks Arun.
( at April 1, 2018 2:45 am)
0

I don’t have a clue what you are trying to do here. Please post this as a new question and provide a screenshot of what you are trying to achieve.

( at April 1, 2018 8:35 am)