Stock: Technical Analysis
Motivated by e-mail from Jim B.

Many stock trading strategies involve staring at charts of Stock Price, Moving Averages, Exponential Moving Averages, MACD, RSI, Stochastics ...

>Huh?
All that stuff is here, but let's recap a wee bit:

• MA (Moving Average) of prices P:
1. Pick a number, like N = 20.
2. Generate MA = Average of Stock Prices over the last N days.
• EMA (Exponential Moving Average) of prices P:
1. Pick a number, like N = 20 and calculate A = 1 - 2/(N+1).
3. Generate today's 20-day EMA from yesterday's like so:   EMA[today] = A*EMA[yesterday] + (1-A)*P[today].
• MACD (Moving Average Convergence Divergence):
1. Pick two numbers, like N = 12 and M = 26.
2. Generate:   MACD = (12-day EMA) - (26-day EMA).
3. Generate, in addition, the MACD "trigger" = 9-day EMA of MACD. (It smooooths out the MACD curve.)
• RSI (Relative Strength Index):
1. Pick a number like N = 14.
2. Calculate U = the Average of stock Price Increases over the past N days. (If it's not an Increase, ignore it.)
3. Calculate D = the Average of stock Price Decreases over the past N days. (If it's not an Decrease, ignore it.)
4. Generate:   RSI = 100*{ 1 - 1/(1+U/D) }. (U and D are both non-negative. If D = 0 you're in BIG trouble.)
• RSC (Relative Strength Comparison):
1. Pick a number like N = 14 and a "Benchmark" or Index. (Like the DOW.)
2. Calculate P = the Stock Price Gain over the past N days.
3. Calculate Q = the Index Gain over the past N days.
4. Generate:   RSC = 100*P/Q. (If it's greater than 100 you're laughin' ... cause the Stock is doin' better than the Index, eh?)
• Stochastics (Fast and Slow):
1. Pick a number like N = 14.
2. Note today's price, P.
3. Determine H = the largest stock Price over the past N days.
4. Determine L = the smallest stock Price over the past N days.
5. Generate:   %K Stochastic = 100*(P - L) / (H - L).
6. Generate, in addition, %D Stochastic = 3-day MA of %K. (It smooooths out the "fast" %K stochastic curve.)
>Don't tell me!! You stick all this in a spreadsheet, right?