Expansion Area MA Lines & Bubble

Whistler

New member
I’ve seen the ability to plot the moving average for a timeframe other than the current chart as a short straight line with its chart bubble in the far right portion of the expansion area. The attached chart has daily timeframe EMAs plotted on a 1 minute chart. To me this seems like it would be a great way of tracking those levels without interfering with price plots. But I have a hard time understanding how thinkscript handles time designations, especially time periods beyond the current. Does anybody have any ideas on how to go about coding a way of doing this?

This is my first time trying to post an image. I don't see it in the preview even though I followed the usethinkscript directions. But the image should be viewable at
RsH7lju


RsH7lju
 
Solution
I’ve seen the ability to plot the moving average for a timeframe other than the current chart as a short straight line with its chart bubble in the far right portion of the expansion area. The attached chart has daily timeframe EMAs plotted on a 1 minute chart. To me this seems like it would be a great way of tracking those levels without interfering with price plots. But I have a hard time understanding how thinkscript handles time designations, especially time periods beyond the current. Does anybody have any ideas on how to go about coding a way of doing this? hal_bub

to draw objects after the last bar, you can use offsets on variables to reference the last bar, x number of bars back.

here is an example to,
draw a line...
I’ve seen the ability to plot the moving average for a timeframe other than the current chart as a short straight line with its chart bubble in the far right portion of the expansion area. The attached chart has daily timeframe EMAs plotted on a 1 minute chart. To me this seems like it would be a great way of tracking those levels without interfering with price plots. But I have a hard time understanding how thinkscript handles time designations, especially time periods beyond the current. Does anybody have any ideas on how to go about coding a way of doing this? hal_bub

to draw objects after the last bar, you can use offsets on variables to reference the last bar, x number of bars back.

here is an example to,
draw a line after the last bar.
..can pick how many bars after last bar.
..can pick how long the line is, in bars.

draw a bubble after the last bar

Code:
# future_line_02

# plot a line, x bars after last bar, y bars long
def na = double.nan;
def bn = barnumber();

# set this to the desired signal
def data = close;

# last bar
def lastbar = !isnan(close[0]) and isnan(close[-1]);
def lastbarnum = if barnumber() == 1 then 0 else if lastbar then barnumber() else lastbarnum[1];

# get price from last bar, and keep
def lastdata = if barnumber() == 1 then 0 else if lastbar then data else lastdata[1];

input bars_after_last_bar = 3;
def ba = bars_after_last_bar;

input line_x_bars_long = 7;
def bl = line_x_bars_long;

def line_en = !isnan(close[ba + bl - 1]) and isnan(close[ba - 1]);

plot z = if line_en then lastdata else na;
#z.SetStyle(Curve.MEDIUM_DASH);
z.SetDefaultColor(Color.cyan);
#z.setlineweight(1);
z.hidebubble();

# --------------------------

# plot a bubble, x bars after last bar
input show_bubble = yes;

# calc future bar
input bars_in_future = 5;
def bif = bars_in_future;

def cl = close;
def x = IsNaN(cl[bif]) and !IsNaN(cl[bif + 1]);

# read price level from the last bar
def vert = close[bif + 1];
AddChartBubble(show_bubble and x, vert, "$" + vert, Color.WHITE, yes);
#

6r4EH90.jpg
 
Last edited:
Solution

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

halcyonguy - Wow! Thank you so much. This is doing exactly what I wanted it to do. And now I have a much better idea of how thinkscipt handles some of these concepts. I'll work with it some and get back with any questions, but I think you've left it pretty self-explanatory at this point. Thanks again!
 
Using this to cleanup my daily chart, thank you! Specifying after which bar the line begins is awesome, I don't recall seeing that before.
 
Last edited:
Love it but is there a way to put daily levels on a smaller timeframe - 5m chart for example showing me what the yesterdays close for example.
sure, just need to change a couple formulas, replace close with a different variable.

line data
def data = close;

bubble data
def vert = close[bif + 1];

just be aware that close , or whatever, has an offset to point back at the last bar, to read a valid price.

i think that already exists on here somewhere... or somethingthing similar. i'm remembering several colored, horizontal lines, after the last bar. will see if i can find it.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
350 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top