StockFetcher Forums · Filter Exchange · Slope of moving averages<< >>Post Follow-up
snappyfrog
721 posts
msg #161159
Ignore snappyfrog
6/22/2024 6:43:48 PM

Here is a first try at writing this formula into code.
Looks quite promising so far. I am going to try several moving averages to see which I like best.
Comments, additions, changes welcome!

/*MA Slope = [MAc – MAn]/n
Where:
MAc = current value of the moving average
MAn = the value of the moving average n-periods ago
n = number of periods ago*/

Fetcher[
market is not otcbb
market is not etf
price > 5
volume > 1000001
set{var1, MA(5) - MA(5) 10 days ago}
set{var4, var1 / 10}
add column var4
draw var4 line 0
and var4 crossed above 0
]



snappyfrog
721 posts
msg #161160
Ignore snappyfrog
6/22/2024 6:47:12 PM

More info:

Why use moving average slope?
The moving average slope can tell you the momentum of the moving average relative to some time in the past. That is, when the moving average is increasing in value, staying flat, or decreasing. This, in turn, tells you the strength of the trend.

Also, when using two MAs of different periods to indicate the short-term and long-term trends, their slopes can show you when both the short-term and long-term trends are in the same direction, which presents a better and less-risky time to enter a trade in that direction.

How to use the moving average slope
Ordinarily, when using a moving average indicator, you can visually gauge the slope of the moving average — at least, you can see whether the slope is upward (uptrend), flat (sideways), or downward (downtrend). In fact, if you are observant, you can see when the slope is getting steeper (stronger trend) or less steep (declining trend).

However, you can code or pay someone to code a custom indicator that measures slope and displays it as an indicator line on the chart. This can make the use of moving average slope easier for you.

How can you use the slope of a moving average in trading?
There are many ways you can use the slope of a moving average in guiding your trading decisions. The simplest one is to find the direction of the trend when using a single moving average. In this case, if the slope is upward, the market is likely in an uptrend, and if it is downward, the market is likely in a downtrend. When the slope is flat, the market is probably range-bound.

You can also employ the strategy of the relative slope by using two moving averages of different periods to show the long-term and short-term trends. In this case, when the slope of both moving averages is upward, it means that both the short-term and long-term trends are in the same direction: upward. So, it is safe to go long. If the long-term MA Slope is upward, but the short-term one is downward, it may be best to wait for both to align before you make a trade.

Similarly, if both long-term and short-term MA slopes are downward, it may be safe to take a short position in the market.

styliten
294 posts
msg #161161
Ignore styliten
6/22/2024 9:00:55 PM

If you’d like, you can add the following at the end:

draw clri(clri(ma(5) multiply by 1.750, 5) minus clri(ma(5) 10 days ago multiply by 0.750, 5), 10) on plot price
draw clri(clri(ma(5) multiply by 1.625, 5) minus clri(ma(5) 10 days ago multiply by 0.625, 5), 10) on plot price
draw clri(clri(ma(5) multiply by 1.500, 5) minus clri(ma(5) 10 days ago multiply by 0.500, 5), 10) on plot price
draw clri(clri(ma(5) multiply by 1.375, 5) minus clri(ma(5) 10 days ago multiply by 0.375, 5), 10) on plot price
draw clri(clri(ma(5) multiply by 1.250, 5) minus clri(ma(5) 10 days ago multiply by 0.250, 5), 10) on plot price
draw clri(clri(ma(5) multiply by 1.125, 5) minus clri(ma(5) 10 days ago multiply by 0.125, 5), 10) on plot price
draw clri(clri(ma(5) multiply by 1.001, 5) minus clri(ma(5) 10 days ago multiply by 0.001, 5), 10) on plot price
draw clri(clri(ma(5) multiply by 0.875, 5) minus clri(ma(5) 10 days ago multiply by -.125, 5), 10) on plot price
draw clri(clri(ma(5) multiply by 0.750, 5) minus clri(ma(5) 10 days ago multiply by -.250, 5), 10) on plot price

draw clri(clri(ma(5) 10 days ago multiply by 1.750, 5) minus clri(ma(5) multiply by 0.750, 5), 11) on plot price
draw clri(clri(ma(5) 10 days ago multiply by 1.625, 5) minus clri(ma(5) multiply by 0.625, 5), 11) on plot price
draw clri(clri(ma(5) 10 days ago multiply by 1.500, 5) minus clri(ma(5) multiply by 0.500, 5), 11) on plot price
draw clri(clri(ma(5) 10 days ago multiply by 1.375, 5) minus clri(ma(5) multiply by 0.375, 5), 11) on plot price
draw clri(clri(ma(5) 10 days ago multiply by 1.250, 5) minus clri(ma(5) multiply by 0.250, 5), 11) on plot price
draw clri(clri(ma(5) 10 days ago multiply by 1.125, 5) minus clri(ma(5) multiply by 0.125, 5), 11) on plot price
draw clri(clri(ma(5) 10 days ago multiply by 1.001, 5) minus clri(ma(5) multiply by 0.001, 5), 11) on plot price
draw clri(clri(ma(5) 10 days ago multiply by 0.875, 5) minus clri(ma(5) multiply by -.125, 5), 11) on plot price
draw clri(clri(ma(5) 10 days ago multiply by 0.750, 5) minus clri(ma(5) multiply by -.250, 5), 11) on plot price

snappyfrog
721 posts
msg #161162
Ignore snappyfrog
6/23/2024 10:13:30 AM

I tried a couple of them. I like seeing that over the price chart. Thanks.

snappyfrog
721 posts
msg #161172
Ignore snappyfrog
modified
6/30/2024 2:08:03 PM

This is the code I finalized. I am going to use this on the 3 stocks in the symlist. The
intention is for fast 2 -5 day trades up and down for 1% - 5% gains on the stocks.

I trade options and they are quite cheap on these 3, so the intention is to use the options
to leverage my gains. Bullish gains on T came out to 1.44% on 5 day trades. With options
I hope to be able to leverage that up to 8% - 10% on trades.

Also, with options I am not limited to only bullish trades, so I will short via options also. This
will allow me to be in all 3 stock trades to the upside and downside at all times, or at least
when I feel it has the potential to move.

The oscillators below the chart are only to help me gauge strength and weakness while in the trade.

Fetcher[
apply to symlist(t,pltr,f)
and draw ema(13)

/*Adding slope of MA*/
set{var1, MA(5) - MA(5) 5 days ago}
set{var2, var1 / 5}
add column var2
draw var2 line 0
set{var5, count(var2 above var2 5 day low,1)}
draw var5
set{var6, count(var2 below var2 5 day high,1)}
draw var6

draw Stochastic %K(20,20,2) line 50
draw Stochastic %K(40,40,4) line 50

draw cma(ASI,3)
do not draw ASI
draw rsi(10) line 60

add column separator
add column sector
add column industry
]



StockFetcher Forums · Filter Exchange · Slope of moving averages<< >>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.