15 day uptrend?

bullman1083

New member
Hi guys, New to script and trading, Trying to write script for indicator when stock is up 12 of last 15 days, volume up 25% or more in 15 days and price up20% or more in last 15 days. Any help appreciated thanks.
 
Solution
Code:
input lookback_window = 15;
input minimum_hits = 12;

# define spikes
def volume_spike = if volume > (volume[lookback_window] * 1.25) then 1 else 0;
def price_spike = if close > (close[lookback_window] * 1.20) then 1 else 0;

# define trend -- for each up day, we put 1 in a series and then sum them and see whether there have been 12 or more in the last 15
def price_trend = if close > close[1] then 1 else 0;
def price_in_uptrend = if sum(price_trend, lookback_window) >= minimum_hits then 1 else 0;

# use our defined values to look for hits
plot hit = if volume_spike == 1 AND price_in_uptrend == 1 AND price_spike == 1 then 1 else double.nan;

I honestly have no idea if that will 'hit' anything or not, but the scan should work. Be sure you set it to work on...
Code:
input lookback_window = 15;
input minimum_hits = 12;

# define spikes
def volume_spike = if volume > (volume[lookback_window] * 1.25) then 1 else 0;
def price_spike = if close > (close[lookback_window] * 1.20) then 1 else 0;

# define trend -- for each up day, we put 1 in a series and then sum them and see whether there have been 12 or more in the last 15
def price_trend = if close > close[1] then 1 else 0;
def price_in_uptrend = if sum(price_trend, lookback_window) >= minimum_hits then 1 else 0;

# use our defined values to look for hits
plot hit = if volume_spike == 1 AND price_in_uptrend == 1 AND price_spike == 1 then 1 else double.nan;

I honestly have no idea if that will 'hit' anything or not, but the scan should work. Be sure you set it to work on the D (day) aggregation period and hope for the best.

I think I interpreted you volume spike and price spike correctly: today's volume or price is that much larger than the value on the single day 15 days ago. If that's not right, let me know.

-mashume
 
Solution

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

Thread starter Similar threads Forum Replies Date
bullman1083 Moving Average Uptrend >= 20 days Questions 5
M Scan for uptrend Questions 14
D Downtrend/Uptrend for VIX Questions 1
B largest gain/range since uptrend Questions 18

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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