@JamesB
OK. I'll bite.
I've written about angles around here somewhere before, but I can't find it at the moment. The issue with trying to describe an angle for the movement of an average is that what you think of as angles generally have fixed units for x and y -- centimeters, kilometers, etc... -- and what you have for a moving average for a financial instrument is price vs time. You can talk about rates in finance (as in +5¢ per hour or -$0.0025 per minute) the same way you can talk about highway grades (100 feet per mile up, etc...) but it is very hard to talk about the angles of a moving average as you can adjust both the vertical resolution and the timeframe in so many ways.
Add to this that, as you noted above, the way we calculate a slope in ThinkScript is to look at the change from some point in the past (in the case above I believe the angle was calculated from the 3 bar linear regression slope). The minimum distance for finding an angle in ThinkScript is going to be 2 bars. This bar and the last.
IF the curve of the moving average had a nice clean mathematical definition (as a function of t) then you could find the derivative of it at the final point in time (at time t) and determine the slope of the line at a single point. But we don't generally have nice mathematical functions for price movement. If you have found one, please do post it here though.
That said, I believe what you're looking for is a way to determine whether the 50SMA is moving up or down. or is largely flat. If you use this bar and the last bar as the two points for the slope of your line, the you would have something like this:
Code:
declare lower;
def sma_length = 50;
def slope_lookback = 1;
def SMA = Average(close, sma_length);
def height = AbsValue(SMA - SMA[slope_lookback]);
plot SMAAngle = (ATan(height / slope_lookback) * 180) / Double.Pi;
You can then do a comparison of the value of the SMAAngle this bar with the value from some point in the past if you want.
There are more advanced statistical things you can do with a slope, including z-scores to determine whether the current slope is in line with the slope from the last n bars or whether it is different in a statistically significant way. You can plot the slope vs 0, or deviation from 0. You can remove the absValue function and integrate (sum) over the last n bars to decide how flat it has been (the closer to 0 the flatter).
What you do with this information is up to you. There are a great many talented coders around here who can help, if you can define what it is you want (mathematically or simply as specifically as you can in non-math terms). However, without better specs and an example or two (images are great, with annotations are better -- your investment of time and sweat are generally appreciated when asking for help) it will be difficult for people to help out much beyond what is here already.
Good luck and happy trading,
-mashume