StockFetcher Forums · General Discussion · Newbie needs some help....please!<< >>Post Follow-up
17 posts
msg #110352
Ignore timfor
1/19/2013 1:45:34 AM


I will be the first to admit that I couldn't code my way out of a wet paper bag to save my own life so I'm hoping some of you much smarter coding wizards can save my sorry ass from having to struggle with stockfetcher code.

What I want to be able to do is have a scan that looks at a weekly stock charts and find stocks where the price is diverging from the 50 period simple moving average.

I would like to have this scan (perhaps two separate versions of code required for each scan?) cover both scenarios where price is moving up as the 50 sma is heading down and where price is moving down while the 50 sma is moving up.

Again, this would be on a weekly time frame.

Thanks in advance to anyone who can code this scan for me....I will be eternally grateful!!!


683 posts
msg #110363
Ignore duke56468
1/19/2013 4:43:10 PM

Not sure what good it is but maybe this will get you started.

Fetcher[weekly ma(50) is below weekly ma(50) 1week ago
weekly close is above weekly close 1 week ago
chart-display is weekly

485 posts
msg #110366
Ignore guru_trader
1/19/2013 11:51:00 PM

How you define divergence is also important ... divergence over what period of time (how many weeks)? What % of divergence is considered significant enough for you?

17 posts
msg #110399
Ignore timfor
1/22/2013 1:55:18 AM

Duke and Guru,

Thanks for your responses and the code.

Guru, you raise good points that I didn't think to mention on my original post. So, to answer your questions....

I would like a scan that finds divergences of one weekly bar with the option to, hopefully, be able to change the code in the future as required to do two or three weekly bars, etc. I want to start with one weekly bar for now though to test with.

The other item you mentioned relates to the percentage of divergence. I'm not entirely clear on what you mean here but I think it might relate to the slope of the 50SMA. The greater the slope the higher the percentage perhaps? I know in stockfetcher you can use code to define the slope of the moving average. If you could include some code that would allow me to specify the slope of the 50sma then that would likely do the trick.

I found this chunk of code relating to the slope of a moving average and this might be what is needed although I'll refer to your experience to use the right code. "Show Stocks where the 3 day slope of the MA(50) is above .01"

I hope that answers your questions.

Duke, if you could alter the code you so generously provided to account for the slope of the 50sma and allow for one weekly bar only, that would be greatly appreciated.

Thanks again gentlemen for your time, I value it very much!


17 posts
msg #110436
Ignore timfor
1/22/2013 6:39:41 PM


StockFetcher Forums · General Discussion · Newbie needs some help....please!<< >>Post Follow-up

*** Disclaimer *** does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. does not recommend particular securities., Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.

Copyright 2018 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus