MTF Last Month's High, Low, Close

traderjoe777

New member
Based on Saty Mahajan's Golden Gate Strategy, I am trying to create a scanner (Simplified version below) (let's call it golden_gate_scanner) which relies on 4 things, "high", "low", "close" of last month and close price today (or 1 day before). Below is the algorithm.
  1. Based on the previous months high, low & close. We calculate the ATR value (Wilders) say atr.
  2. Using this expression (previous_month_close + (atr * 0.382)) we get a value, say upper_trigger
  3. Plot the upper_trigger & if today's close crosses it then the ticker should appear in our scan/watchlist.
I have coded the above logic & have added a filter with the following condition on ToS scan tab.
  1. close is greater than or equal to golden_gate_scanner()."upper_trigger" with the aggregation period of "D".
As thinkorswim cannot aggregation 2 different periods (Month and Day in this case), Is there a way we can create a scan for this scenario? I believe we can because Saty's website indicates that it exists. Any inputs are highly appreciated.
Thank you.

Ruby:
input use_current_close = no;
input atr_length = 14;

def trading_period = AggregationPeriod.MONTH;

def previous_close = close(period = trading_period)[if use_current_close then 0 else 1];
def atr = Round(WildersAverage(TrueRange(high(period = trading_period), close(period = trading_period), low(period = trading_period)), atr_length)[if use_current_close then 0 else 1], 2);

def upper_0382 = previous_close + (atr * 0.382);

plot upper_trigger = upper_0382;

 
This is not supported. See this link for more details.
https://usethinkscript.com/threads/answers-to-commonly-asked-questions.6006/post-72503

Thus, there is no need to mention aggregation period within the scan, because you can only use one at a time in the Stock Hacker tab. If you do mention an aggregation period, it would have to be the same as the aggregation chosen for the scan, which would be redundant.

As far as a potential workaround, the closest I can get to your intent is to compare the current month's close to last month's upper 0382.

Also, you could really only see if current month's close is greater than or equal to last month's upper 0382.[if you take the [1] off the upper_0382 in the value below and scan, you should see zero results, because upper_0382 = the close + more stuff.

Code:
# create this scan using monthly aggregation
input atr_length = 14;

def atr = Round(WildersAverage(TrueRange(high, close, low), atr_length), 2); 

def upper_0382 = close + (atr * 0.382); # upper 0382

plot scan = close >= upper_0382[1]; # compare current  close to prior upper 0382

# assuming this scan is done at monthly aggregation
 

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

Thread starter Similar threads Forum Replies Date
B show only last period of MTF MA Questions 2
E MTF Bar Counting Questions 1
S MTF EMA Trend Questions 1
Z MTF Heiken-Ashi Trend Line Questions 1
D MTF High Low Close Lines Questions 5

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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