Welcome to T2W 73sand.
The formula is here, and there are also plenty of other formulae in case you feel adventurous.
and this link has the formula already done in TradeStation language:
R Squared in Metastock is:
Pwr(Corr(Cum( 1 ),C,14,0),2)
or, for a smoothed version:
Mov(Pwr(Corr(Cum( 1 ),C,14,0),2)*100,14,S)
I believe that probably the most indepth analysis of this is in book The New Technical Trader by Chande & Kroll. I've not got the book though, so I cannot confirm this.