Don't have any script yet. For example, I want to show the cloud (it will be a vertical bar) if inside bar is forming. The bar should go away if inside bar condition is false or the bar closes (even if it stays inside)
# insidebar_lastbar_0
# https://usethinkscript.com/threads/addcloud-hide-remove.12419/#post-106669
# show a vertical bar if inside bar is forming, on the last bar.
# The bar should go away if inside bar condition is false or the bar closes (even if it stays inside)
#yellow outline, addchart()
#https://usethinkscript.com/threads/draw-a-box-around-the-overnight-session-on-futures-intraday-charts.2087/page-3#post-58481
#sleepyz
input tickoffset = 5;
input charttype = ChartType.CANDLE;
def o = open;
def h = high;
def l = low;
def c = close;
def nan = Double.NaN;
def lastbar = !isnan(close) and isnan(close[-1]);
def inside = (high <= high[1] and low >= low[1]);
def cond = lastbar and inside;
def o1 = if cond then h + TickSize() * tickoffset else nan;
def c1 = if cond then l - TickSize() * tickoffset else nan;
def h1 = if cond then h + TickSize() * tickoffset else nan;
def l1 = if cond then l - TickSize() * tickoffset else nan;
DefineGlobalColor(color = Color.YELLOW, name = "Box");
AddChart(growcolor = GlobalColor("Box"), high = h1, low = l1, open = c1, close = o1, type = charttype);
#
Don't have any script yet. For example, I want to show the cloud (it will be a vertical bar) if inside bar is forming. The bar should go away if inside bar condition is false or the bar closes (even if it stays inside)
Ruby:input showmiddlecloud = yes; input showoutsideverticallines = yes; def inside = high < high[1] && low > low[1]; #Cloud def insideh = if showmiddlecloud and IsNaN(inside[-1]) and inside then Double.POSITIVE_INFINITY else Double.NaN; def insidel = if showmiddlecloud and IsNaN(inside[-1]) and inside then Double.NEGATIVE_INFINITY else Double.NaN; AddChart(if close > open then insideh else Double.NaN, insidel, insideh, insidel, ChartType.CANDLE, growColor = Color.GREEN); AddChart(if close < open then insideh else Double.NaN, insidel, insideh, insidel, ChartType.CANDLE, growColor = Color.RED); #Vertical Lines AddVerticalLine(showoutsideverticallines and IsNaN(inside[-1]) and inside, "", if close > open then Color.GREEN else Color.RED, Curve.FIRM); AddVerticalLine(showoutsideverticallines and IsNaN(inside[-2]) and inside[1], "", if close[1] > open[1] then Color.GREEN else Color.RED, Curve.FIRM);
the yellow box does go away. it only exists on the last bar.Even with your script, anyway to remove the yellow box once that bar closes?
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
![]() |
Show or Hide AddCloud() Function | Questions | 16 | |
S | How to Fill Gaps in AddCloud function | Questions | 3 | |
M | AddCloud not working for MACD Histogram | Questions | 2 | |
C | Tri_Colored AddCloud | Questions | 1 | |
L | How to hide all but the last chart bubble? | Questions | 4 |
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.