PureBytes Links
Trading Reference Links
|
Can you optimize two securities with one trading system giving the results
on both securities.
We do pairs trading, in other words, go long and short of two securities
simultaneously. A strategy in Tradestation should therefore identify a
buy/sell signal (that part is no problem), but then issue a buy signal for
security and a simultaneous sell signal for security B - something I have
been unable to figure out. I use a two - symbol chart (insert a second
symbol into a chart. Easy Language references both easily in doing any
calculation, but can seemingly only issue a signal on the first one. The
reserved word: [This Bar] refers to the first security only and on the
trading test it appears as such. Is there ANY way I can convince the program
to trade both securities?
Here is the code for a simple pairs trading strategy:
Input: Input1(close of data1),
Input2(close of data2),
Length(30),
SD(1);
Var: Filter(0), { Filtered version of ratio }
StdErr(0), { Standard error magnitude }
BBTop(0), { Top band }
BBBot(0), { Bottom band }
ratio(1);
{ Calc Ratio of security A to security B }
ratio = Input1/Input2;
{ Calc filter (simple moving average at this point }
Filter = Average(ratio,Length);
{ Define one standard error }
StdErr = StdDev(ratio, Length);
{ Define error bands }
BBTop = Filter + SD*Stderr;
BBBot = Filter - SD*StdErr;
{ signal for upper band breakout }
If Ratio Crosses Above BBTop Then Buy ("MAC") This Bar on Close;
The last line issues the BUY signal, but it implies a buy on Input1 only
Any help
Gary
|