combining a study with a time period.

megazord

New member
Hey!
So I have been running P/L backtesting a bit with some strategies. I want to make a script that essentially outputs whether their are squeezes on the weekly, daily, and 4h time frames. I have been trying to convert some multi-time frame indicators into it with no luck. I am wondering if one can combine a study (ttm_squeeze) with an aggregation period. Essentially something like
"def wsqz = for aggregation.week !TTM_Squeeze().SqueezeAlert; "
so that I can throw that on for the different time frames and then put that into a buy order to see how it would have performed. Is this possible? or do I need to go through one of the recreations of the squeeze on this site? and that still kinda leaves me with the same logical problem. I feel like I have missed a reserved word or operator.
Any help would be great!
 
If I am not mistaken, you can only access multiple time frames from functions which include a period parameter. This is generally reserved for basic price fundamentals like open, high, low, close, etc. You would most likely have to recreate the study, or modify an existing recreation, and access multiple time frames at a deeper level within the code.

However, if I am wrong, that would actually be great. I'd rather be wrong about this one. So if anybody else can correct me, please do so.
 

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

Wait, scratch that, that TTM thing has Close as a parameter. So you should be able to submit the secondary aggregation by nesting it in.
 
CSS:
plot mTTM = ttm_Squeeze(close(period = AggregationPeriod.MONTH));
plot wTTM = ttm_Squeeze(close(period = AggregationPeriod.WEEK));
plot dTTM = ttm_Squeeze(close(period = AggregationPeriod.DAY));

Hope that helps, I don't use any of these squiggle doodle generators myself, what would represent the "signal" or what ever that you're looking for? Are they supposed to happen at the same time on all time frames... or just any one of them happening?
 
Ruby:
def mTTM = ttm_Squeeze(close(period = AggregationPeriod.MONTH)).SqueezeAlert;
def wTTM = ttm_Squeeze(close(period = AggregationPeriod.WEEK)).SqueezeAlert;
def dTTM = ttm_Squeeze(close(period = AggregationPeriod.DAY)).SqueezeAlert;
plot Result = dTTM or wTTM or mTTM;

Ok, ok, sorry for so many posts, this is probably it... but this is just a guess.

You can add in additional aggregations if you want, should be easy to figure out from here.

You can switch the or to and if you want them all at the same time, but that does not appear to be the case.

You must run the script on the lowest, or a lower aggregation than the shortest in use, for it to work.

Also make sure, if you're running it intra-day, that you're time frame setup has enough historic data, ie more than a month in this case.

Otherwise, you're going to have to check each value with IsNaN() and pass it through as a 0 or No if it isn't a number.

... and I just realized that performing those checks myself in the code would have been easier than explaining it.

But its too late now, I'm not gonna.

GLHF
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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