Join useThinkScript to post your question to a community of 21,000+ developers and traders.
thanks for the reply. appreciate it. this community seems nice and active!@tatl
close[1] or GetValue(close,1), depends on the context.
Why do you want to change it? You're opening yourself up for skewed results and in the case of strategies impossible trade prices.
awesome ok here you are@tatl
Would have to see the code in which it is being used.
lets say I had a simple bar chart indicator in blue, but I wanted it to print a yellow bar behind the blue bars which was an average of the last three blue values. what would the code look like?
and then further.....what if i wanted those yellow bars to only print Every Three Bars? so it would go blue - blue - blue/yellow - blue - blue - blue/yellow.
# skipcntavg
def bn = barnumber();
def na = double.nan;
input skip = 3;
input offset_average = 0;
input hide_main_price_candles = no;
HidePricePlot(hide_main_price_candles );
def x = if (bn % skip == 0) then 1 else 0;
def opnx = if !x then na else average(open[offset_average], skip);
def hix = if !x then na else average(high[offset_average], skip);
def lox = if !x then na else average(low[offset_average], skip);
def clsx = if !x then na else average(close[offset_average], skip);
AddChart(high = hix, low = lox, open = opnx, close = clsx, type = ChartType.CANDLE, growcolor = Color.yellow);
input test1_bubbles = no;
addchartbubble(test1_bubbles, low, bn , color.yellow, no);
#
def percentmoved = (((high-low)/open) * 100);
plot volumeperpercent = (volume/percentmoved);
volumeperpercent.SetPaintingStrategy(paintingstrategy.HISTOGRAM);
this draws yellow candles, every x bars, that are an average of the past x bars.
can pick how many bars to skip.
can pick an offset for the prices used in the average.
. if 0 is used, the average starts on the current candle.
. if 1 is used, the average starts on the previous candle.
can turn off the main price candles.
this uses addchart(), to draw candles
Ruby:# skipcntavg def bn = barnumber(); def na = double.nan; input skip = 3; input offset_average = 0; input hide_main_price_candles = no; HidePricePlot(hide_main_price_candles ); def x = if (bn % skip == 0) then 1 else 0; def opnx = if !x then na else average(open[offset_average], skip); def hix = if !x then na else average(high[offset_average], skip); def lox = if !x then na else average(low[offset_average], skip); def clsx = if !x then na else average(close[offset_average], skip); AddChart(high = hix, low = lox, open = opnx, close = clsx, type = ChartType.CANDLE, growcolor = Color.yellow); input test1_bubbles = no; addchartbubble(test1_bubbles, low, bn , color.yellow, no); #
![]()
with main price candles turned off
![]()
ref - draw candles. can pick solid or hollow.
https://usethinkscript.com/threads/...ower-section-in-thinkorswim.10428/#post-92412
How do we read the bubble numbers? I see its named as test. Does it mean that its beta?![]()
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.