Mark Minervini, Trend Template TOS Scanner

N

Nick

Active member
2019 Donor
VIP
Gave this a little bit more flexibility to be able to switch it to other numbers, securities, etc. Also, the multiplier was supposed to 100, not 10 like posted here. For some reason the indices are cutting off at the end of 2019, so I just switched it to spy for now.
Code:
declare lower;

input Correlation_with_Security = "SPY";
input length = 200;
input Period = AggregationPeriod.DAY;
input averagetype = AverageType.Simple;

def price = close;
def RSD = close/(close(correlation_with_security));
def RSDavg = MovingAverage(averagetype, RSD, length);

plot RSM = (( RSD / RSDavg) - 1 ) * 100;
plot zeroline = 0;

zeroline.SetDefaultColor(GetColor(2));
@wtf_dude hi, for my learning, may request you to explain what does this scan do? what type of stocks can we get from this scan? Can i change this to weekly timeframe, if so, what input length is recommended... thank you very much
 
R

Rbuzon

New member
@wtf_dude Thank You for finding the RSI portion, i am trying to put it in all together but im getting an error "Exactly one plot expected"

any advice would help


## 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])
declare lower;

input Correlation_with_Security = "SPY";
input length = 200;
input Period = AggregationPeriod.DAY;
input averagetype = AverageType.Simple;

def price = close;
def RSD = close/(close(correlation_with_security));
def RSDavg = MovingAverage(averagetype, RSD, length);

plot RSM = (( RSD / RSDavg) - 1 ) * 100;
plot zeroline = 0;

zeroline.SetDefaultColor(GetColor(2));
#
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
;
 
T

Thomas

Active member
@wtf_dude Thank You for finding the RSI portion, i am trying to put it in all together but im getting an error "Exactly one plot expected"

any advice would help


## 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])
declare lower;

input Correlation_with_Security = "SPY";
input length = 200;
input Period = AggregationPeriod.DAY;
input averagetype = AverageType.Simple;

def price = close;
def RSD = close/(close(correlation_with_security));
def RSDavg = MovingAverage(averagetype, RSD, length);

plot RSM = (( RSD / RSDavg) - 1 ) * 100;
plot zeroline = 0;

zeroline.SetDefaultColor(GetColor(2));
#
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
;

OK, all fixed,.....any more difficulties, let me know.

#Copy this code into scanner.....add "volume," 1Mil,........"Last, 5"..........


## 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])
declare lower;

input Correlation_with_Security = "SPY";
input length = 200;
input Period = AggregationPeriod.DAY;
input averagetype = AverageType.Simple;

def price = close;
def RSD = close/(close(correlation_with_security));
def RSDavg = MovingAverage(averagetype, RSD, length);

Def RSM = (( RSD / RSDavg) - 1 ) * 100;
#plot zeroline = 0;

#zeroline.SetDefaultColor(GetColor(2));

plot data = (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
;
 
Last edited:
B

Bamilus

New member
@wtf_dude Thank You for finding the RSI portion, i am trying to put it in all together but im getting an error "Exactly one plot expected"

any advice would help


## 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])
declare lower;

input Correlation_with_Security = "SPY";
input length = 200;
input Period = AggregationPeriod.DAY;
input averagetype = AverageType.Simple;

def price = close;
def RSD = close/(close(correlation_with_security));
def RSDavg = MovingAverage(averagetype, RSD, length);

plot RSM = (( RSD / RSDavg) - 1 ) * 100;
plot zeroline = 0;

zeroline.SetDefaultColor(GetColor(2));
#
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
;

Not trying to be pedantic but want to clarify because this is an extremely common mistake.

Relative Strength does not equal Relative Strength Index. The former is comparing the relative performance of one ticker vs another. The second is a momentum oscillator that compares an individual stocks rate of change and looks for oversold and overbought opportunities. They are used for entirely different reasons and cannot be used interchangeably.
 
W

Winston

New member
Hi,

I am new here, hoping I can get some help. Hopefully it wasn't address before. I am looking to do a scan pre-market for stocks that are trading sideways. Thanks in advance.
  • 1. FastSma and SlowSMA within a certain PERCENT of each other
    • Able to change both SMA input
    • Able to change the PERCENT

  • 2. Stock Price within a certain Percent of the SMA
    • Able to which SMA
    • Able to change Stock Price Percent within SMA
 
M

mashy

New member
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
Very Nice,...Do you mind sharing your script.
 
B

Break Trader

New member
just an idea! is anyone able to code the 4 stages Mark uses? something to mark on charts or in a watchlist to make an easy glace to know what stage the stock is in and from the watch list knowing without even looking at the chart
 
Last edited:
M

Moose

New member
Gave this a little bit more flexibility to be able to switch it to other numbers, securities, etc. Also, the multiplier was supposed to 100, not 10 like posted here. For some reason the indices are cutting off at the end of 2019, so I just switched it to spy for now.
Code:
declare lower;

input Correlation_with_Security = "SPY";
input length = 200;
input Period = AggregationPeriod.DAY;
input averagetype = AverageType.Simple;

def price = close;
def RSD = close/(close(correlation_with_security));
def RSDavg = MovingAverage(averagetype, RSD, length);

plot RSM = (( RSD / RSDavg) - 1 ) * 100;
plot zeroline = 0;

zeroline.SetDefaultColor(GetColor(2));
I don't remember where I copied this script. Maybe it has some value:

#I just looked at the code for the "RelativeStrength" study (not to be confused with Wilder's Relative Strength Index (RSI)) and it is quite possibly the worst script in the TOS library. It is patently useless as it merely divides the current stock's price by the comparison stock's price. The RS should be calculated by taking the rate of change over a period for the current stock divided by the rate of change over the same period for the comparison stock or index. Apples to apples, instead of AAPLs to watermelons.



#So here's a version of the RS based on H.M. Gartley's "Relative Velocity" (the original RS) work. Note that any value greater than 100 means the current stock is leading the comparison stock, conversely values under 100 mean that the comparison stock is outperforming the current stock.

Code:
# script by rhouser

#

declare lower;



input Comparison_Security = "SPX";

input period              = 10;

input price               = FundamentalType.CLOSE;



def comparisonPrice       = fundamental( price, Comparison_Security );

def comparisonRtOfChg     = comparisonPrice / comparisonPrice[ period ];



def currentStkPrice       = fundamental( price );

def currentStkRtOfChg     = currentStkPrice / currentStkPrice[ period ];



plot RS                   = if IsNaN( comparisonRtOfChg ) then Double.NaN else ( currentStkRtOfChg / comparisonRtOfChg ) * 100;

RS.setDefaultColor(GetColor(6));

RS.HideBubble();



plot BaseLine             = 100;

BaseLine.SetDefaultColor( Color.red );

BaseLine.HideBubble();

BaseLine.HideTitle();



#2) The SCAN script -- assumes you named the chart study "RS"

#RS( "SPX", 10, FundamentalType.CLOSE ).RS > 100



#3) The CUSTOM COLUMN script -- assumes you named the chart study "RS"

#plot RS = RS( "SPX", 10, FundamentalType.CLOSE ).RS;

#AssignBackgroundColor( if RS >= 100 then Color.UPTICK else Color.DOWNTICK );



#end
 

Similar threads

Top