newbie Q: TOS scan with bounded price above a moving average

polaris8030

New member
I am just starting on TOS. Stock scan seems quite powerful but I am stumbling on using the moving average study using the GUI
What I would like:
result = (moving_average)(1+lower_bound) < current_daily_close < (moving_average)(1+upper_bound)

for example: return all stocks that are above a moving average at least 2% but no greater than 20%
where moving average could be defined in mins, days, weeks, or months

thanks
-Patrick
 
Solution
I am just starting on TOS. Stock scan seems quite powerful but I am stumbling on using the moving average study using the GUI
What I would like:
result = (moving_average)(1+lower_bound) < current_daily_close < (moving_average)(1+upper_bound)

for example: return all stocks that are above a moving average at least 2% but no greater than 20%
where moving average could be defined in mins, days, weeks, or months

thanks
-Patrick


here are 2 studies for testing, and upper and a lower.
i think the lower can be used as a scan.

the upper one shows red vertical lines when the close is in the range.
the lower one shows a spike when the close is in the range.

test with TSLA, or NVDA , with 2 and 20%. most stocks won't generate...
I am just starting on TOS. Stock scan seems quite powerful but I am stumbling on using the moving average study using the GUI
What I would like:
result = (moving_average)(1+lower_bound) < current_daily_close < (moving_average)(1+upper_bound)

for example: return all stocks that are above a moving average at least 2% but no greater than 20%
where moving average could be defined in mins, days, weeks, or months

thanks
-Patrick


here are 2 studies for testing, and upper and a lower.
i think the lower can be used as a scan.

the upper one shows red vertical lines when the close is in the range.
the lower one shows a spike when the close is in the range.

test with TSLA, or NVDA , with 2 and 20%. most stocks won't generate triggers over 2%.

upper

Code:
# scan_near_avg_rng_upper

#https://usethinkscript.com/threads/newbie-q-tos-scan-with-bounded-price-above-a-moving-average.15747/
# Q: TOS scan with bounded price above a moving average
#I am just starting on TOS. Stock scan seems quite powerful but I am stumbling on using the moving average study using the #GUI
#What I would like:
#result = (moving_average)(1+lower_bound) < current_daily_close < (moving_average)(1+upper_bound)
#for example: return all stocks that are above a moving average at least 2% but no greater than 20%
#where moving average could be defined in mins, days, weeks, or months


def na = double.nan;
def bn = barnumber();

def price = close;
input ma1_len = 21;
input ma1_type =  AverageType.EXPONENTIAL;
def ma1 = MovingAverage(ma1_type, price, ma1_len);

plot z1 = ma1;

input upper_bound = 20.0;
input lower_bound = 2.0;

def upper1 = (ma1 * (1 + upper_bound/100));
def lower1 = (ma1 * (1 + lower_bound/100));

plot z2 = upper1;
plot z3 = lower1;

def x1 = ( close >= lower1 and close <= upper1);
addverticalline(x1, "-");
#


---------------

lower

Code:
# scan_near_avg_rng_lower

#https://usethinkscript.com/threads/newbie-q-tos-scan-with-bounded-price-above-a-moving-average.15747/
#newbie Q: TOS scan with bounded price above a moving average

declare lower;

def na = double.nan;
def bn = barnumber();

def price = close;
input ma1_len = 21;
input ma1_type =  AverageType.EXPONENTIAL;
def ma1 = MovingAverage(ma1_type, price, ma1_len);

input upper_bound = 20.0;
input lower_bound = 2.0;

def x = (close >= (ma1 * (1 + lower_bound/100))) and (close <= (ma1 * (1 + upper_bound/100)));

plot z = x;
#


TSLA 15min 6/8+
vXzBJX7.jpg
 
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
410 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