♥ 0 |
I tried to display a bubble at the mid point of a plot. Tried in two ways. (1) One show at the mid point of the chart excluding expansion area on the right. (1) Second at Mid point of the chart including expansion area. First one does not work. But Second one works. My code is as follows (with comments next to the code) declare lower; Plot Line1=1; def lastBar = if IsNaN(close())then double.Nan else barNumber() ; #(last bar was at 61) def TotBars = HighestAll(BarNumber()); #(including 10 bar expansion, total bars=71) AddLabel( yes, Concat(lastBar, TotBars), Color.RED ); * shows correctly 61 and 71 AddChartBubble( barNumber() ==lastBar/ 2 or barNumber() == ((lastBar / 2) + .5), 1, concat(barnumber(), lastBar ) , Color.YELLOW, yes); #prints at bar#1 and shows LastBar=1 AddChartBubble( barNumber() == TotBars / 2 or barNumber() == ((TotBars / 2) + .5), 0, Concat(barnumber(), totBars) , Color.YELLOW, yes); #prints correctly at bar 36 shows totBars=71 I feel I do not understand how Thinkscript variables work (or made some stupid error!~). I am confused why the value of totbars remained unchanged at 71 while Lastbar was changed to 1 and did not remain at 61. Also note that lastBar was not set to 2, 3 at each bar but stopped at 1. Thanks
Marked as spam
|
Please log in to post questions.
Yes. This Plot technique is ia fantastic idea that I learnt from you now..OK..I see my real problem as well. I intuitively (and now I see, correctly) thought that Think Script may assign the variable for each bar but then I immediately, without thinking through and noting that barNumber() ==lastBar/ 2 or lastBar/ 2 +.5 can only be true for 1, I somehow felt that if it evaluates for each bar then it should print a bubble for each bar. Stupid error, but in the process I learnt a great technique, Pete. Thank you.
Love to hear that. Awesome! Congrats and have fun!