Site Meter The Lawyer Trader: Using a Correlation Indicator in Trading--Plus the TOS Script

Tuesday, February 8, 2011

Using a Correlation Indicator in Trading--Plus the TOS Script

I've recently been utilizing a correlation indicator with my intraday trading.  In particular, I like to use a correlation indicator with Think or Swim when trading the Eur/Usd...I like to follow the correlation of the Eur/Usd to the E-Mini futures contract (/es).  This can be beneficial when you like to use market internals while trading.  For instance, I'm always watching NYSE Advance/Declines, NYSE UpVolume vs. DownVolume, the TICK and the VIX.  These indicators are great for trading stocks but are sometimes useless when trading a currency pair or commodity.

The answer?  Watch a correlation chart of the pairs.  When the correlation is strong and rising, the market internals are more useful for trading the Eur/Usd and when the correlation is weak and falling, I know to ignore them.  Here's a chart:
So as you can see, the Blue Line is the actual correlation and the Blue and Purple histogram is the spread between the 20 period EMA of the Correlation and the Correlation.  The histogram helps with the determination of whether the correlation is growing stronger and weaker and the actual correlation line is helpful to know how correlated the securities are.  This type of strategy is helpful with currencies, but it can also be applied to all types of trading:  stocks, sectors, commodities, and futures of all sorts.  For instance, you can watch the correlation between the gold contract and Gold Corp (GG) when day trading GG.  Or the correlation between gold and equities in general could be helpful too.  Just food for thought. 

In case any of you out there like to dabble with Think or Swim scripts here's the code for this indicator.  It is just a modified version of the correlation indicator that comes stock with think or swim.  Here you go:

 ######################################
declare lower;

input length = 50;
input correlationWithSecurity = "/ES";
input MAPeriod = 20;

def Correlation = correlation(close, close(correlationWithSecurity), length);

def correlationavg = ExpAverage(correlation, MAPeriod);

plot data = Correlation - correlationavg;

plot data2 = correlation;

data2.setdefaultColor(color.blue);

def data3 = 0;


data.SetPaintingStrategy(paintingstrategy.histogram);

data.assignvaluecolor(if data>0 then getcolor(1) else getcolor(0));

addcloud(data2, data3, getcolor(1), getcolor(0));
###################################################

Hope all is well with everyone!

TLT

2 comments:

Rebecca D. McNeely said...

I think this is one of the most significant information for me. And i’m glad reading your article. But should remark on some general things, The web site style is perfect, the articles is really great : D. Good job, cheers fxgm za

NiceFreshClean said...

Thank you very much for keep this information. 70trades