Alternate Symbol MACD Indicator for Think or Swim

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!

This indicator is free. You can download “AltMACDSTUDY.ts” from “Released Thinkscript Studies” on my Google site. Thanks for (hopefully still) reading!

Tags: ,

5 Responses to “Alternate Symbol MACD Indicator for Think or Swim”

  1. Fifth_Street Says:

    Thank you! It seems like only one MA plotted into the code. How can i make standard MACD crossover?

  2. Prospectus Says:

    Change the line that says Def macdma=average(MACD,periodhist);

    To Plot macdma=average(MACD,periodhist);

  3. Fifth_Street Says:

    Yes, there is crossover.
    Thanks a lot P!

  4. NJB Deflator Says:

    How do I change the settings so that it loads the MACD for any given ticker, not the input in the study settings?

  5. Prospectus Says:

    Not sure what you’re asking, Deflator?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: