Mark Minervini Trend Template ThinkorSwim Scanner

Awesome, thank you so much!!
Alright, this hits all of the criteria from what I can tell but I also added a fall in bollinger band width to make sure volatility itself is contracting. Not a fan so far. Probably needs more tweaking and good luck getting it to scan (Without timing out).

Code:
# VCP indicator translated from AFL
# WTF_Dude 4.29.21

declare upper;

input longperiod = 128;
input base_Lower_Limit = 30;
input shortperiod = 5;
input shortdepthmax = 10;

####

def LongTop = Highest(high, longperiod);
def LongBottom = Lowest(low, longperiod);

def longdepth = (LongTop - LongBottom) / LongTop;
def LongDepthTarget = longdepth <= .3;

def highdist = GetMaxValueOffset(high, longperiod);
def lowdist = GetMinValueOffset(low, longperiod);


### Volume Target Criteria

def reglength = 20;
def volavg = simpleMovingAvg(volume,50);
def volreg = linearRegressionSlope(volavg,reglength);

def VolTarget = volreg <= 0;

###################



### Short term depth

def ShortTop = Highest(high, shortperiod);
def ShortBottom = Lowest(low, shortperiod);
def ShortDepth = (ShortTop - ShortBottom) / ShortTop;

def shortdepthtarget = ShortDepth < shortdepthmax / 100;



##### Bollinger Bandwidth Decreasing

input BBaverageType = AverageType.Simple;
def price = close;
def displace = 0;
def length = 20;
def Num_Dev_Dn = -2.0;
def Num_Dev_Up = 2.0;

def upperBand = BollingerBands(price, displace, length, Num_Dev_Dn, Num_Dev_Up, BBAverageType).UpperBand;
def lowerBand = BollingerBands(price, displace, length, Num_Dev_Dn, Num_Dev_Up, BBaverageType).LowerBand;
def midLine = BollingerBands(price, displace, length, Num_Dev_Dn, Num_Dev_Up, BBaverageType).MidLine;

def Bandwidth = (upperBand - lowerBand) / midLine * 100;

def BWavg = simplemovingavg(bandwidth,20);
def BWavgSlope = linearRegressionSlope(bwavg,20);
def BBbwSlopeTarget = BWavgSlope<0;


#### Nav Labels



addlabel(yes, "High Dist: " + highdist,color.light_Gray);
addlabel(yes, "Low Dist: " + lowdist,color.light_Gray);

addlabel(yes, "Depth: " + Longdepth,color.light_Gray);
addlabel(yes, "Depth%: " + aspercent(Longdepth),color.light_Gray);
addlabel(yes, "Short Depth: " + aspercent(ShortDepth), color.light_Gray);
addlabel(yes, "Volavgslope: " + volreg, color.light_gray);
addlabel(yes, "BBwidthSlope: " + BWavgSlope, color.light_Gray);

def finalcontract = close<=highest(close, shortperiod);
def upmove1 = close> longbottom and close>shortbottom;
def upmove2 = close>lowest(close,shortperiod);


#### Plotting type

plot VCP = LongDepthTarget  and VolTarget and shortdepthtarget and BBbwSlopeTarget  and finalcontract and upmove1 and upmove2;
#and lowafterhightarget and VolTarget and shortdepthtarget and BBbwSlopeTarget;

VCP.SetPaintingStrategy(PaintingStrategy.boolean_points);
VCP.SetDefaultColor(Color.cyan);
VCP.setlineWeight(1);
 
Last edited:
You really shouldnt just use random indicators or scans without understanding them (even though many people on this forum do.)

This scan is the first step of many steps in Marks SEPA system. The purpose of this scan is to find stocks in confirmed uptrends. From there, you filter through the charts and fundamentals. Mark will never trade anything without showing VCP characteristics (violatility contraction pattern). In the past month Id say about 50% of the stocks from this scan meet my low fundamental criteria (so i weed out the clearly bad ones). From there about another 20-25% get weeded out when i analyze their fundamentals more. Im usually left with 100 to 150 stocks and out of those usually only 10% or less are showing VCP characteristics.

Kroger and Campbells arent high growth stocks and therefore would not have passed Marks fundamental scan. Secondly, neither has shown VCP, therefore no buy point has been triggered. Lastly, both stocks have been laggards and have had RS in the 80s at best. Mark only wants the stocks leading the market and he buys them after they come out of a base with a VCP.

Ive been studying stocks and investing since I was 13 and it still took me 4 or 5 times of reading both of Marks books to grasp everything. Its not that complex, but you have to be very precise. This is not an improperly backtested system where you see a random indicator light up and you hit "buy" like a brainless monkey.

If you need more guidance after reading both of his books then PM me and I can give you some helpful resources.

Exit: so you know, i run this scan with the following filters

Price 10$ or greater (mark usually doesnt buy stocks lower than that and it weeds out a ton of garbage stocks)
50 day moving avg of volume 150k of greater (weed out thinly traded junk)
Mansfield rs above 0 (see my posts above for formula)
Filter on all listed stocks (dont want otc garbage)
Exclude etfs (some etfs still sneak into the results but this weeds out most)

After that i have a custom excel sheet which brings in the scan results and weeds out any stock that has an IBD rs rating of 79 or less and ibd composite rating of 69 or less. From there i analyze the charts and fundamentals more in depth. As i said, recently ive been getting 250 to 270 on this TOS scan and the initial IBD criteria filters down to about 100 to 150. From there only about 50 to 100 meet my more stringent fundamental criteria and of those only about 5 to 15 are showing strong technical activity which includes VCP. These are the ones i watch to buy when their stock moves through the pivot point on heavy volume
Hi @Bamilus, Trade like a stock market wizard Mark's book just arrived, and one of the first things I thought was to search here in this forum about a "SEPA" indicator. But it seems it's only your post relating to that. Do you know which scanners and indicators should I focus on?

Thank you
 
Alright, this hits all of the criteria from what I can tell but I also added a fall in bollinger band width to make sure volatility itself is contracting. Not a fan so far. Probably needs more tweaking and good luck getting it to scan (Without timing out).

Code:
# VCP indicator translated from AFL
# WTF_Dude 4.29.21

declare upper;

input longperiod = 128;
input base_Lower_Limit = 30;
input shortperiod = 5;
input shortdepthmax = 10;

####

def LongTop = Highest(high, longperiod);
def LongBottom = Lowest(low, longperiod);

def longdepth = (LongTop - LongBottom) / LongTop;
def LongDepthTarget = longdepth <= .3;

def highdist = GetMaxValueOffset(high, longperiod);
def lowdist = GetMinValueOffset(low, longperiod);


### Volume Target Criteria

def reglength = 20;
def volavg = simpleMovingAvg(volume,50);
def volreg = linearRegressionSlope(volavg,reglength);

def VolTarget = volreg <= 0;

###################



### Short term depth

def ShortTop = Highest(high, shortperiod);
def ShortBottom = Lowest(low, shortperiod);
def ShortDepth = (ShortTop - ShortBottom) / ShortTop;

def shortdepthtarget = ShortDepth < shortdepthmax / 100;



##### Bollinger Bandwidth Decreasing

input BBaverageType = AverageType.Simple;
def price = close;
def displace = 0;
def length = 20;
def Num_Dev_Dn = -2.0;
def Num_Dev_Up = 2.0;

def upperBand = BollingerBands(price, displace, length, Num_Dev_Dn, Num_Dev_Up, BBAverageType).UpperBand;
def lowerBand = BollingerBands(price, displace, length, Num_Dev_Dn, Num_Dev_Up, BBaverageType).LowerBand;
def midLine = BollingerBands(price, displace, length, Num_Dev_Dn, Num_Dev_Up, BBaverageType).MidLine;

def Bandwidth = (upperBand - lowerBand) / midLine * 100;

def BWavg = simplemovingavg(bandwidth,20);
def BWavgSlope = linearRegressionSlope(bwavg,20);
def BBbwSlopeTarget = BWavgSlope<0;


#### Nav Labels



addlabel(yes, "High Dist: " + highdist,color.light_Gray);
addlabel(yes, "Low Dist: " + lowdist,color.light_Gray);

addlabel(yes, "Depth: " + Longdepth,color.light_Gray);
addlabel(yes, "Depth%: " + aspercent(Longdepth),color.light_Gray);
addlabel(yes, "Short Depth: " + aspercent(ShortDepth), color.light_Gray);
addlabel(yes, "Volavgslope: " + volreg, color.light_gray);
addlabel(yes, "BBwidthSlope: " + BWavgSlope, color.light_Gray);

def finalcontract = close<=highest(close, shortperiod);
def upmove1 = close> longbottom and close>shortbottom;
def upmove2 = close>lowest(close,shortperiod);


#### Plotting type

plot VCP = LongDepthTarget  and VolTarget and shortdepthtarget and BBbwSlopeTarget  and finalcontract and upmove1 and upmove2;
#and lowafterhightarget and VolTarget and shortdepthtarget and BBbwSlopeTarget;

VCP.SetPaintingStrategy(PaintingStrategy.boolean_points);
VCP.SetDefaultColor(Color.cyan);
VCP.setlineWeight(1);
Thank you very much for sharing, nice job!

I have one question, let's say a stock $XYZ traded at $100 127 days ago, then went up to $300 100days ago, then retreated to $210 80 days ago. It should be a candidate of VCP. When it comes to the code from above,

def LongTop = Highest(high, longperiod);
def LongBottom = Lowest(low, longperiod);

def longdepth = (LongTop - LongBottom) / LongTop;
def LongDepthTarget = longdepth <= .3;

The highest will be 300 and the lowest will be 100, longdepth will be 0.67, which will disqualify this stock. Correct? So the lowest has to be after the highest, how can we achieve that?

Cheers
 
Below is the scan conditions for ThinkorSwim based on Mark Minervini’s Trend Template.

Code:
##########################################################################################################################
##  1. The current stock price is above both the 150-day (30-week) and the 200-day (40-week) moving average price lines.
##  2. The 150-day moving average is above the 200-day moving average.
##  3. The 200-day moving average line is trending up for at least 1 month (preferably 4?5 months minimum in most cases).
##  4. The 50-day (10-week) moving average is above both the 150-day and 200-day moving averages.
##  5. The current stock price is trading above the 50-day moving average.
##  6. The current stock price is at least 30 percent above its 52-week low. (Many of the best selections will be 100 percent, 300 percent,
##     or greater above their 52-week low before they emerge from a solid consolidation period and mount a large scale advance.)
##  7. The current stock price is within at least 25 percent of its 52-week high (the closer to a new high the better).
##  8. The relative strength ranking (as reported in Investor?s Business Daily) is no less than 70, and preferably in the 80s or 90s,
##     which will generally be the case with the better selections
##  NOTE: Point 8, I have not implemented, because TOS doesn'thave IDB rating.
##
## Reference to conditions above
##     3)     (Average(close, length) > Average(close, length)[LookBack])
##     2) and SimpleMovingAvg("length" = 150)."SMA" is greater than SimpleMovingAvg("length" = 200)."SMA"
##     4) and SimpleMovingAvg("length" = 50)."SMA"  is greater than SimpleMovingAvg("length" = 150)."SMA"
##     4) and SimpleMovingAvg("length" = 50)."SMA"  is greater than SimpleMovingAvg("length" = 200)."SMA"
##     1) and close is greater than SimpleMovingAvg("length" = 200)."SMA"
##     1) and close is greater than SimpleMovingAvg("length" = 150)."SMA"
##     5) and close is greater than SimpleMovingAvg("length" = 50)."SMA"
##     6) and price > x
##     7) and price > y
##########################################################################################################################

## Code Start

input range = 252;                                                            #Number of Trading days
input price = close;                                                          #Current closing price
input length = 200;                                                           #hint length: The length of the moving average
input LookBack = 60;                                                          #hint LookBack: The agg-bars back moving average being compared to

def lo = lowest(low,range);
def hi = highest(high,range);

#The current stock price is at least 30 percent above its 52-week low.
def x = 1.3 * lo;           #30%  above its 52-week low
#def x = 2.0 * lo;           #100% above its 52-week low

#The current stock price is within at least 25 percent of its 52-week high
def y = 0.75 *  hi;         #25%  of its 52-week high
#def y = 0.80 *  hi;         #20%  of its 52-week high
#def y = 0.90 *  hi;         #10%  of its 52-week high

# The below reads as SimpleMovingAvg("length" = 200) is greater than SimpleMovingAvg("length" = 200) from 60 agg-bars ago.
#(Average(close, length) > Average(close, length)[LookBack])

plot scan = (Average(close, length) > Average(close, length)[LookBack])
and SimpleMovingAvg("length" = 150)."SMA" is greater than SimpleMovingAvg("length" = 200)."SMA"
and SimpleMovingAvg("length" = 50)."SMA"  is greater than SimpleMovingAvg("length" = 150)."SMA"
and SimpleMovingAvg("length" = 50)."SMA"  is greater than SimpleMovingAvg("length" = 200)."SMA"
and close is greater than SimpleMovingAvg("length" = 200)."SMA"
and close is greater than SimpleMovingAvg("length" = 150)."SMA"
and close is greater than SimpleMovingAvg("length" = 50)."SMA"
and price >= x
and price >= y
;
https%3A//i.imgur.com/fTc8nPf.jpg[/img]']
fTc8nPf.jpg


Hi, i have a dumb question, to use this script to scan the uptrend stock, do we set "as true" within how many bar? or we just select as value?
And if we want to use this for weekly timeframe,what adjustments we need to make to the script...

Thank u
 
Here's a different way to identify VCP. Below is the code for the momentum squeeze from else where on this site. If you install this code and look at the daily chart for GOOGL, then look at the dates of March 2021. It will all be in grey, indicating a squeeze. As you can see on April 1, the stock blasted off and ran up 16% in 19 trading days.

Code:
# Momentum Squeeze
# Mobius
# Added Squeeze Label with directional color
# Label is green when momentum is ascending, red when descending

input length = 20; #hint length: Length for average calculation
input price = close;
input SDmult = 2.0;
input ATRmult = 1.5;

def K = (Highest(High, length) + Lowest(low, length)) / 2 + ExpAverage(close, length);
def Momo = Inertia(price - K / 2, length);
def SD = StDev(close, length);
def Avg = Average(close, length);
def ATR = Average(TrueRange(high, close, low), length);
def SDup = Avg + (SdMult * Sd);
def ATRup = Avg + (AtrMult * ATR);

def Squeeze = if SDup < ATRup then 0 else Double.NaN;

assignpriceColor(if squeeze ==0 then color.gray else
if momo > momo[1] then color.blue else color.red
);

AddLabel(!isNaN(Squeeze), "Squeeze", if isAscending(Momo)
                                     then Color.Green
                                     else Color.Red);
 
hi guys, i have been working on trying to develop a scanner that searches for stock that meet Minervini Trend template, then show a 3-week base and or 3 weeks tight range, which then would hope to combine the "blast off" or inside day candle with the last 3 days of volume decreasing
here is what i have but they dont seem to all work together and my coding experience is very limited, can some look at this and see if anyone can figure out a way to combine or write a scan to something like this? https://tos.mx/M6tTJPo
thank you in advance
 
hi guys, i have been working on trying to develop a scanner that searches for stock that meet Minervini Trend template, then show a 3-week base and or 3 weeks tight range, which then would hope to combine the "blast off" or inside day candle with the last 3 days of volume decreasing
here is what i have but they dont seem to all work together and my coding experience is very limited, can some look at this and see if anyone can figure out a way to combine or write a scan to something like this? https://tos.mx/M6tTJPo
thank you in advance
I think it would be great if this raises interest in the community. I played with it a little and came up with one decent setup... $DLTR but then this market isn't exactly the best environment for bullish charts of any sort.

Good luck!
 
I think it would be great if this raises interest in the community. I played with it a little and came up with one decent setup... $DLTR but then this market isn't exactly the best environment for bullish charts of any sort.

Good luck!
The biggest problem im seeing with it. is it isnt picking up the last candle within 1% range and it isnt picking up the 3 days decreasing volume.
it will pick them up in separate scans with only the sole condition, but all mixed in they are not all working together
 
Alright, this hits all of the criteria from what I can tell but I also added a fall in bollinger band width to make sure volatility itself is contracting. Not a fan so far. Probably needs more tweaking and good luck getting it to scan (Without timing out).

Code:
# VCP indicator translated from AFL
# WTF_Dude 4.29.21

declare upper;

input longperiod = 128;
input base_Lower_Limit = 30;
input shortperiod = 5;
input shortdepthmax = 10;

####

def LongTop = Highest(high, longperiod);
def LongBottom = Lowest(low, longperiod);

def longdepth = (LongTop - LongBottom) / LongTop;
def LongDepthTarget = longdepth <= .3;

def highdist = GetMaxValueOffset(high, longperiod);
def lowdist = GetMinValueOffset(low, longperiod);


### Volume Target Criteria

def reglength = 20;
def volavg = simpleMovingAvg(volume,50);
def volreg = linearRegressionSlope(volavg,reglength);

def VolTarget = volreg <= 0;

###################



### Short term depth

def ShortTop = Highest(high, shortperiod);
def ShortBottom = Lowest(low, shortperiod);
def ShortDepth = (ShortTop - ShortBottom) / ShortTop;

def shortdepthtarget = ShortDepth < shortdepthmax / 100;



##### Bollinger Bandwidth Decreasing

input BBaverageType = AverageType.Simple;
def price = close;
def displace = 0;
def length = 20;
def Num_Dev_Dn = -2.0;
def Num_Dev_Up = 2.0;

def upperBand = BollingerBands(price, displace, length, Num_Dev_Dn, Num_Dev_Up, BBAverageType).UpperBand;
def lowerBand = BollingerBands(price, displace, length, Num_Dev_Dn, Num_Dev_Up, BBaverageType).LowerBand;
def midLine = BollingerBands(price, displace, length, Num_Dev_Dn, Num_Dev_Up, BBaverageType).MidLine;

def Bandwidth = (upperBand - lowerBand) / midLine * 100;

def BWavg = simplemovingavg(bandwidth,20);
def BWavgSlope = linearRegressionSlope(bwavg,20);
def BBbwSlopeTarget = BWavgSlope<0;


#### Nav Labels



addlabel(yes, "High Dist: " + highdist,color.light_Gray);
addlabel(yes, "Low Dist: " + lowdist,color.light_Gray);

addlabel(yes, "Depth: " + Longdepth,color.light_Gray);
addlabel(yes, "Depth%: " + aspercent(Longdepth),color.light_Gray);
addlabel(yes, "Short Depth: " + aspercent(ShortDepth), color.light_Gray);
addlabel(yes, "Volavgslope: " + volreg, color.light_gray);
addlabel(yes, "BBwidthSlope: " + BWavgSlope, color.light_Gray);

def finalcontract = close<=highest(close, shortperiod);
def upmove1 = close> longbottom and close>shortbottom;
def upmove2 = close>lowest(close,shortperiod);


#### Plotting type

plot VCP = LongDepthTarget  and VolTarget and shortdepthtarget and BBbwSlopeTarget  and finalcontract and upmove1 and upmove2;
#and lowafterhightarget and VolTarget and shortdepthtarget and BBbwSlopeTarget;

VCP.SetPaintingStrategy(PaintingStrategy.boolean_points);
VCP.SetDefaultColor(Color.cyan);
VCP.setlineWeight(1);
Pls help to clarify the use of the last paragraphs on “plot VCP”, how could be shown on chart, Tks
 
Pls help to clarify the use of the last paragraphs on “plot VCP”, how could be shown on chart, Tks
Don't even remember this indicator, but it's just showing you dots above the bars whenever it fits all the criteria of a vcp
 
Hi guys , does anyone have Minervinis 1 month trend template code. For finding power plays ?
his 1 month or 4 month templates are literally just that first coding you see on this thread but it defines how long the 200ma has been going up for. So for the 1 month template you would just change "lookback" to 21 . 21 days = 1 month. change 'lookback' to 84 if you want the 4 month template.
 
his 1 month or 4 month templates are literally just that first coding you see on this thread but it defines how long the 200ma has been going up for. So for the 1 month template you would just change "lookback" to 21 . 21 days = 1 month. change 'lookback' to 84 if you want the 4 month template.

Thanks but for some reason it still give me all the same stocks for the 5 month trend template. I dont know what im doing wrong.


Is the original code a 5 month trend template ?
 
Last edited by a moderator:
Thanks but for some reason it still give me all the same stocks for the 5 month trend template. I dont know what im doing wrong.


Is the original code a 5 month trend template ?
60 days. It writes that out in plain text in the code. The lookback entry is how many days the 200ma should have been going up
 

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
347 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