## Archive for September, 2010

### Alternate Symbol MACD Indicator for Think or Swim

September 21, 2010

I’ve been so busy, gotten sick, had work deadlines, that I’ve been away from the blog for ages. I’m making a renewed push at all my projects, so here’s an indicator that was requested by a reader: A MACD that follows an symbol independent of the symbol of the underlying chart. You could use this to plot the MACD of the VIX onto a chart of the VXX ETF for example. Or to plot the broad market SPY on an individual stock you are watching.

Anyway, here’s how to do it:

A MACD is just a distance between two moving averages. The histogram is a distance between the MACD line and a moving average of that line. So we will build our own MACD from scratch using data from the symbol we are interested in.

Traditionally, the MACD uses exponential moving averages. I don’t know that it matters, but I do prefer exponential over simple because of the way they blend out past data. So we start with the inputs for the symbol and the MACD periods:

Input symbol=”VIX”;
Input period1=12;
input period2=26;
input periodhist=9;

Next we create the two exponential averages for the MACD line:

Def exp1=expaverage(close(symbol),period1);
Def exp2=expaverage(close(symbol),period2);
Plot MACD=exp1-exp2;
Def macdma=average(MACD,periodhist);
Plot Hist=MACD-macdma;

Add some formatting and that’s it!