custom indicator correlation

 

I hope I can explain this indicator with enough detail. What I would like is a custom indicator that tracks the correlation between two pairs for a variable number of periods, using the current period. For instance, the gold standard USD/CHF EUR/USD. If I want a noisier correlation, could use over 10,12,15 periods. If I want it to be smoother, change the # periods to 50+. I have been using a buy/buy on the eurusd and usdchf, closing out the two when the overall value is up, and even adding another position when the overall position is down, and I am hoping to gain when the value returns to the near -1. My problem is timing. If the correlation is near -1 as it usually is, then it is a no brainer. If the correlation breaks it will either go net up or net down. When the correlation breaks, I could use the indicator as a timing tool.

When the correlation is nowhere near -1, it could also be either a very profitable time to enter or a very foolish time to enter.

 

have fun with it

Files:
 

I have it in my custom indicators folder, can see it from the navigator, but I can't get it to launch. Could I be doing something wrong?