Getting data(volume) from a different timeframe than the current chart displayed?

Is it possible to get the data(volume) from the 1 minute timeframe when viewing the 15 minute chart? I would like to create a label that has the volume of the last 1 minute candle while viewing a 15 minute chart (or any larger timeframe than the 1 minute)

I noticed in the thinkorswim manual under MIN aggregation period it says, "aggregation period used in this example cannot be less than chart aggregation period." Does that mean it's not possible?

As a basic example here is what I have tried (finding the volume of the last 1' candle and comparing it to the previous 50 1' candles to see if there is a volume spike while viewing a 15' timeframe):

Code:
input length = 50;
def agg = AggregationPeriod.MIN;

def volbuzz = (volume[1]/Average(volume, 50)) * 100;

AddLabel(1, "Vol: " +
    Round(volbuzz, 0)
    + "%",
    if volbuzz >= 200 then color.MAGENTA
    else color.gray);

But when I switch the chart to the 15' (higher) timeframe the label doesn't show up.
 
Last edited:
You need to change the following:

Code:
def agg = AggregationPeriod.MIN;

to:

Code:
input = AggregationPeriod.MIN;

And then adjust the aggregation period accordingly when you switch between different chart timeframes. In ThinkorSwim, you can display data from a higher timeframe onto a lower timeframe but not the other way around.
 

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

I'm batting 0% now.... Can't get the volume from the 1' timeframe on a higher timeframe, and can't script plot a premarket level on the chart unless you want your VWAP and moving averages skewed by the premarket data!

But thank you for your help. Great site.
 
Take a look at my comment above to find out why.
I did. I changed the the aggregation to input, but when you switch to the 15' and select 1' for the aggregation period in settings it doesn't work (pull the data from the 1'), or are you just confirming what you said that you CAN NOT get data from the 1' onto the 15' minute (or any greater than 1' timeframe, e.g. 2', 5', 15', 30', 1hr...)?
 
Below is the code i just wrote for a MTF Trend label based on 9 and 21 EMA. It looks good on a 5 min chart, but when i move to a higher time frame all the labels disappear even though i have conditioned it. Any help will be greatly appreciated.

Code:
#MTF Trend label based on 9 and 21 EMA
#Author - ThalaDa

input fastlength = 9;
input slowlength = 21;

def TimeFrame5min = AggregationPeriod.FIVE_MIN;
def TimeFrame10min = AggregationPeriod.TEN_MIN;
def TimeFrame15min = AggregationPeriod.FIFTEEN_MIN;
def TimeFrame30min = AggregationPeriod.THIRTY_MIN;
def TimeFrame1hr = AggregationPeriod.HOUR;
def TimeFrameDay = AggregationPeriod.DAY;
def TimeFrameWeek = AggregationPeriod.WEEK;
def TimeFrameMonth = AggregationPeriod.MONTH;

#Get the Current timeframe of the chart
def curAg = GetAggregationPeriod();

#Get the MTF labels that needs to be displayer based on current chart timeframe
def displayX5 = TimeFrame5Min >= curAg;
def displayX10 = TimeFrame10Min >= curAg;
def displayX15 = TimeFrame15Min >= curAg;
def displayX30 = TimeFrame30Min >= curAg;
def displayXH = TimeFrame1Hr >= curAg;
def displayXD = TimeFrameDay >= curAg;
def displayXW = TimeFrameWeek >= curAg;
def displayXM = TimeFrameMonth >= curAg;


def AvgType = averageType.EXPONENTIAL;

def X5 = if displayX5 then MovingAverage(AvgType, close(period = TimeFrame5min), fastlength) > MovingAverage(AvgType, close(period = TimeFrame5min), slowlength) else 0;
def X10 = if displayX10 then MovingAverage(AvgType, close(period = TimeFrame10min), fastlength) > MovingAverage(AvgType, close(period = TimeFrame10min), slowlength) else 0;
def X15 = if displayX15 then MovingAverage(AvgType, close(period = TimeFrame15min), fastlength) > MovingAverage(AvgType, close(period = TimeFrame15min), slowlength) else 0;
def X30 = if displayX30 then MovingAverage(AvgType, close(period = TimeFrame30min), fastlength) > MovingAverage(AvgType, close(period = TimeFrame30min), slowlength) else 0;
def XH = if displayXH then MovingAverage(AvgType, close(period = TimeFrame1hr), fastlength) > MovingAverage(AvgType, close(period = TimeFrame1hr), slowlength) else 0;
def XD = if displayXD then MovingAverage(AvgType, close(period = TimeFrameDay), fastlength) > MovingAverage(AvgType, close(period = TimeFrameDay), slowlength) else 0;
def XW = if displayXW then MovingAverage(AvgType, close(period = TimeFrameWeek), fastlength) > MovingAverage(AvgType, close(period = TimeFrameWeek), slowlength) else 0;
def XM = if displayXM then MovingAverage(AvgType, close(period = TimeFrameMonth), fastlength) > MovingAverage(AvgType, close(period = TimeFrameMonth), slowlength) else 0;


AddLabel(displayX5, “X5”, if X5 then color.Green else color.Red);
AddLabel(displayX10, “X10”, if X10 then color.Green else color.Red);
AddLabel(displayX15, “X15”, if X15 then color.Green else color.Red);
AddLabel(displayX30, “X30”, if X30 then color.Green else color.Red);
AddLabel(displayXH, “XH”, if XH then color.Green else color.Red);
AddLabel(displayXD, “XD”, if XD then color.Green else color.Red);
AddLabel(displayXW, “XW”, if XW then color.Green else color.Red);
AddLabel(displayXM, “XM”, if XM then color.Green else color.Red);
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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