Value from specific time from higher timeframe

C4men

Member
OK I am sure this is possible, but I am currently stumped.

I trade on a 15-minute chart.
Every 30 minutes, I want to "grab" the value of a moving average from a higher timeframe.
Once I have that value, I'd like it to paint on my 15-min chart and display it for 2 bars (30 minutes).

Here's my example:
  1. It's 9:30am
  2. Capture whatever the value of the 9-ema on the 1-HOUR timeframe is at exactly 930am
  3. Paint a horizontal line on my chart using that value
  4. The horizontal line terminates at 9:59am
  5. Process repeats at 10am, with a new line based on the 9ema/1hour value at exactly 10am
  6. And so on...
I've stumbled onto something really cool if I can get this final piece to work.

Can it be done?

Someone help me!!!
 
Solution
lines are drawn of a higher time frame average of close.
a label describes what the line data is.

options:
..wedges (small arrows) drawn every time new data is read from the higher time frame.
..bubbles to display the price level of the average line.

Ruby:
# highertime_lines_00

input data_time_period = AggregationPeriod.hour;
def data_time_min = data_time_period / 60000;

#input display_duration_min = 30;
input display_duration_period = AggregationPeriod.thirty_min;
def display_duration_min = display_duration_period / 60000;

def price = close(period = data_time_period);

input avg1_len = 9;
input avg1_type =  AverageType.EXPONENTIAL;
def ma1 = MovingAverage(avg1_type, price, avg1_len);

def daysec = SecondsFromTime(0000);
def...
lines are drawn of a higher time frame average of close.
a label describes what the line data is.

options:
..wedges (small arrows) drawn every time new data is read from the higher time frame.
..bubbles to display the price level of the average line.

Ruby:
# highertime_lines_00

input data_time_period = AggregationPeriod.hour;
def data_time_min = data_time_period / 60000;

#input display_duration_min = 30;
input display_duration_period = AggregationPeriod.thirty_min;
def display_duration_min = display_duration_period / 60000;

def price = close(period = data_time_period);

input avg1_len = 9;
input avg1_type =  AverageType.EXPONENTIAL;
def ma1 = MovingAverage(avg1_type, price, avg1_len);

def daysec = SecondsFromTime(0000);
def daymin = daysec / 60;
def newdata = if Floor(daymin / display_duration_min) == (daymin / display_duration_min) then 1 else 0;
def level = if !newdata then level[1] else round(ma1, 2);

plot z = level;
z.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
# z.SetStyle(Curve.MEDIUM_DASH);
z.SetDefaultColor(Color.cyan);
# z.setlineweight(1);
z.hidebubble();

addLabel(1, "avg( " + data_time_min + " min , " + avg1_len + " ) , every " + display_duration_min + " min"
, Color.cyan);

input test_show_data_read_bar = yes;
plot z2 = ( test_show_data_read_bar and newdata);
z2.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_up);
z2.SetDefaultColor(Color.cyan);

input test_show_data_bubble = no;
addchartbubble(test_show_data_bubble and newdata, level, level, color.cyan, no);


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

# https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/AverageType
#  EXPONENTIAL
#  HULL
#  SIMPLE
#  WEIGHTED
#  WILDERS
#


N9lLNyd.jpg


inputs
kcoMYsY.jpg
 
Last edited:
Solution

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
305 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