StockFetcher Forums · General Discussion · Moving Average Differential<< >>Post Follow-up
macjoe11
1 posts
msg #159788
Ignore macjoe11
11/17/2022 7:22:05 AM

Can anyone suggest a filter phrase where the difference between two moving averages is less than a percentage of the greater moving average? e.g. 34dMA minus 21dMA is less than, say, 0.5% of the 34dMA?
Thanks.

glgene
616 posts
msg #159791
Ignore glgene
11/17/2022 3:30:35 PM

Try this. If I have misread your desired output, simply switch the ma(34) and ma(21) in the calculation.
-- Gene in FL

Fetcher[
/*symlist(spy,dia,qqq,iwm)*/
dow 30

add column separator
add column ma(34)
add column ma(21)
add column separator
set{a, ma(34)/ma(21)}

set{b, a * 100}
add column b{ma(34)/ma(21).. (100.00=parity)}
add column b 1 day ago {1d ago}
add column b 5 days ago {5d ago}
add column b 10d ago{10d ago}
add column b 21 days ago{1m ago}
add column separator

sort column 9 descending
draw ma(34)
draw ma(21)
]



xarlor
587 posts
msg #159792
Ignore xarlor
11/17/2022 3:31:54 PM

Fetcher[
set{diff,ma(34) - ma(21)}
set{halfp34,ma(34) * .05}
diff < halfp34

add column diff
add column halfp34
draw ma(34)
draw ma(21)
]



glgene
616 posts
msg #159793
Ignore glgene
11/18/2022 8:00:12 AM

Macjoe … The reason I chose my approach of (/) instead of (-) to your question is because a $2.00 “diff” on a $10 stock is not the same as a $2.00 “diff” on a $100 stock or a $2.00 “diff” on a $1,000 stock. By dividing the ema(34) and ema(21) numbers, it equalizes the “diff” to a percentage (%) comparison.

For example, on 11/17/2022, MSFT comes in first at 100.34. That means the “% diff” is +0.34%. AAPL is 98.90, which means the “% diff” is actually -1.10% (98.90 - 100.00). Remember: 100.00 is 100% parity (where both ema(34) and ema(21) are identical numbers). 100.00 is the starting point.

Using (/) in the equation makes the result a “Relative Moving Average.” Which means you can sort on that column (which I did, as you can see) … from highest to lowest.

I added 1 day ago, 5 days ago, 10 days ago and 1 month (21 days) ago … so you can readily view if a stock’s ema(34) vs. ema(21) comparison is improving or getting worse.

Again — from my original post, you may (if I misread your question) want to change the equation by switching the order of ema(34) and ema(21) in the calculation equation.

Hope this helps. I welcome your feedback.

Gene in FL


StockFetcher Forums · General Discussion · Moving Average Differential<< >>Post Follow-up

*** Disclaimer *** StockFetcher.com 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. StockFetcher.com does not recommend particular securities. StockFetcher.com, 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 2022 - 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


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.