Create Stan Weinstein 30 week moving average scan?

@BenTen
Can you, please, help with the following indicator?

Stan Weinstein's MOMENTUM INDEX
Stan Weinstein also uses a 200-day moving average of the daily AD figures, which he calls his Momentum Index (MI).
  • The most important MI signal is crossing the zero line – a move up is bullish, and a move down is bearish.
  • The longer the line has been on the other side of zero, the stronger is the crossing signal.
 
@alokranjan3 @TheGrimmReaper So you just add the 200 SMA to the Daily chart?

YOXobBV.png
 
@alokranjan3 @TheGrimmReaper

Please, use this link. I tried to make it based on Stan Weinstein’s Secrets for Profiting in Bull and Bear Markets. My first contribution to this forum.

http://tos.mx/qyoNOz8

Code:
#Market Momentum Index from Stan Weinstein’s Secrets for Profiting in Bull and Bear Markets



Script for Stan's momentum index

declare lower;
input AvgType = AverageType.WILDERS;
input Length = 200;
input level=0;
input exchange = {default NYSE, NASDAQ, AMEX};

def advnDecn = AdvanceDecline(type = "Advance/Decline Line (Daily)", exchange = exchange);


plot Data = MovingAverage(AvgType, advnDecn, Length);
plot LevelLine = level;

# End Code

http://tos.mx/ZixYnsb

This is the link to chart set-up based on Stan Weinstein’s Secrets for Profiting in Bull and Bear Markets.
 
Last edited by a moderator:
Stan Weinstien's method uses 30 weeks or 10-week moving average, but it only counts Friday's close and ignores the rest of days' close data.

Does anyone know how to get that?

so below the script, we have CLOSE, but we need just Friday's CLOSE data.

Code:
input price = FundamentalType.CLOSE;
input aggregationPeriod = AggregationPeriod.DAY;
input length = 30;
input averageType = AverageType.SIMPLE;

plot MovAvg = MovingAverage(averageType, Fundamental(price, period = aggregationPeriod), length);
 
@yaarione Just curious. Can you explain what would the scanner or Stan Weinstein's method provides? And what are the specifics you can share? I appreciated you. TIA.
I came across his methods and saw a scan requirements and this 30 WEEK MA is one of them.

it's his method...my scan try to find stage 2 just happened or already in stage 2
https://www.chartmill.com/documenta...tors/92-Weinstein-stage-analysis-in-chartmill

scan details are here (but now seeing different criteria in some other sources)
https://www.stockfetcher.com/forums/Filter-Exchange/Stan-Weinstein-Method/37075

my current TOS scan for this^^
https://tos.mx/tWaoPI5
 
do u know the formula?
https://www.chartmill.com/documentation/technical-analysis-indicators/35-Mansfield-Relative-Strength

The formula of this indicator is a bit more complicated than the regular Dorsey RS, but it is worth the read:

RSM = (( RSD(today) /sma(RSD(today), n)) - 1 ) * 100

Where:

So, the Dorsey Relative Strength value is divided by its own n-day moving average and then one is subtracted. If we look at the daily time frame and use 200 for n, this means:

  • We get 0 if the RSD is exactly equal to its 200 day moving average.
  • We get a negative number if the RSD is below its 200 day moving average.
  • We get a positive number if the RSD is above its 200 day moving average.
Most Technical analysts are familiar with the stock price being above or below a certain Simple Moving Average. With Mansfield RS, the same applies: if the relative strength is above its moving average, positive values are seen, if it is below, we see negative values.

Using Mansfield Relative Strength

As with the regular ( Dorsey ) RS, you can use Mansfield RS to examine if a stock performs better than the market. Only the rising or declining of the indicator matters for this.

Stan Weinstein used the indicator only on weekly charts with 52 as the parameter value for n. He insisted that break outs out of a base had to go together with rising relative strength. The Mansfield RS needs to be rising an close to or above 0.

This indicator has the advantage over the Dorsey RS that the values are below or above the 0 line. This allows us to screen for stocks with a MRS value above 0. When we see that the MRS is far above 0 and has been above 0 for some time, we have found a stock that outperforms the market heavily. We can buy this kind of stock when dips occur.

This screen is a modification of the weekly ChartMill Channel breakout screen, which adds the criteria of a rising Mansfield Relative Strength.
 
@yaarione I am using currently Relative strength (SPY) to compare the particular stock.

Code:
declare lower;

input CorrelationWithSecurity = "SPY";
def close2 = close(CorrelationWithSecurity);

plot RS = if close2 == 0 then 0 else close/close2;
RS.setDefaultColor(GetColor(6));

def sr = CompoundValue("historical data" = RS, "visible data" = if isNaN(sr[1]) then RS else sr[1]);
plot SRatio =  sr;
SRatio.setDefaultColor(GetColor(5));

I also have added cloud to the above-
Plot Zeroline = 0;
AddCloud(ZeroLine,MRS,COLOR.RED,COLOR.GREEN);
 
Here is a scan I am using based on Stan Weinstein 's book. I have used it for few months and works pretty well.
I added condition price should close above 20, 50, 150, 200 Day SMA.

https://tos.mx/iJX1Ldl

Here is another one that looks at price crossing above 30 week weighted moving average and Mansfield RS is above 0.

https://tos.mx/UQ6ifif
I'm trying these scans but they are hanging up with the first part of the scan:

Mansfield_Relative_Strength("length" = 52, "period" = "WEEK", "averagetype" = "WEIGHTED")."RSM" is greater than 0

No such function: Mansfield_Relative_Strength at 1:1
No such function: Mansfield_Relative_Strength at 1:1
No such function: Mansfield_Relative_Strength at 1:1
Invalid statement: Unexpected part of function call at 1:91

The portions Mansfield_Relative_Strength and "RSM" are highlighted in red. Can you help me fix this?
 
I'm trying these scans but they are hanging up with the first part of the scan:

Mansfield_Relative_Strength("length" = 52, "period" = "WEEK", "averagetype" = "WEIGHTED")."RSM" is greater than 0

No such function: Mansfield_Relative_Strength at 1:1
No such function: Mansfield_Relative_Strength at 1:1
No such function: Mansfield_Relative_Strength at 1:1
Invalid statement: Unexpected part of function call at 1:91

The portions Mansfield_Relative_Strength and "RSM" are highlighted in red. Can you help me fix this?
The scan is referencing a custom study called Mansfield_Relative_Strength. Can't use w/o that script.
@alokranjan3 hasn't been seen in a while and we don't have any such studies on the forum :(

But from what I have read the Mansfield plots almost identically to our Relative Strength found here:
https://usethinkscript.com/threads/ibd-stock-charts-style-and-scan-for-thinkorswim.532/
 
Last edited:
The scan is referencing a custom study called Mansfield_Relative_Strength. Can't use w/o that script.
@alokranjan3 hasn't been seen in a while and we don't have any such studies on the forum :(

But from what I have read the Mansfield plots almost identically to our Relative Strength found here:
https://usethinkscript.com/threads/ibd-stock-charts-style-and-scan-for-thinkorswim.532/
Sorry for late reply. I have modified how I used Mansfield RS . I will post updated version shortly.
 
Herse is the updated link.

https://tos.mx/a1Xj62W


TI65_count study:



def avgc7=Average(data = CLOSE, length = 7);
def avgc65= Average(data = CLOSE, length = 65) ;

def TI65 = 100*( avgc7/avgc65-1);

#plot TI65_count= sum (TI65>5, 252);

declare once_per_bar;

def UpThreshold = 5;
def DownThreshold = -5;

#
# Common variables. Using variables reduces calls to TOS iData server.
#
def vClose = close;
def nan = Double.NaN;
def bn = BarNumber();

def barUp = TI65>UpThreshold;


def barUpCount = CompoundValue(1, if barUp then barUpCount[1] + 1 else 0, 0);

plot TI65_count= barUpCount ;




Mansfield_count study:


declare lower;

input Correlation_with_Security = "SPY";
input length = 252;
input Period = AggregationPeriod.DAY;
input averagetype = AverageType.weighted;

def price = close;
#def RSD = close/(close(correlation_with_security));
def RSD = average(close,5)/average(close(correlation_with_security),5);

def RSDavg = MovingAverage(averagetype, RSD, length);

def RSM = (( RSD / RSDavg) - 1 ) * 100;
#plot RSM_Avg=average(RSM, 5);
declare once_per_bar;


def nan = Double.NaN;
def bn = BarNumber();

def barUp = RSM>0;


def barUpCount = CompoundValue(1, if barUp then barUpCount[1] + 1 else 0, 0);

plot TI65_count= barUpCount ;
 

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