I've been looking into pair trading and am trying to create a chart of 
the ratio between two stocks for pair trading.

I have been able to create the chart by using parameters to set the 
two stock tickers but I'd like to save a list of these and be able to 
call them up one and a time like regular stocks.

What I have done is create symbols which contain both tickers 
separated by a character.   In other words, if I want to plot the 
ratio of POT to MOS I have created a symbol called POT^MOS.

Then I have put the following code into an indicator where i pull up 
the ticker, split into two symbols and try to plot the ratio.

Ticker=Name();
Ticklen= strlen(ticker);
Spot = strfind(ticker,"^");
Tick1 = strleft(ticker,spot-1);
Tick2 = strright(ticker,ticklen-spot);
C1 = foreign(tick1,"C");
C2 = foreign(tick2,"C");
Ratio = c1/c2;
Plot(ratio,"ratio",colorgreen,styleline);

When I move to this special ticker the normal price chart is blank 
(because there is no real ticker called POT^MOS) so the normal price 
is empty because close is empty.   But, I can not get anything to 
display in this indicator box either.

Should I be able to do this?   Does my code look ok for this?



Reply via email to