Profile Picture

Other Symbol

Posted By ywlee 3 Years Ago
Posted Wednesday May 13 2015

Just wanted to have a better understanding of the OtherSymbols property.

The example in the manual is as follows:

if (Symbol.Name == "QQQQ")
// Don't do any trading for this symbol
BarData QQQQBar = OtherSymbols["QQQQ"].Bars.Current;
if (QQQQBar.Close > QQQQBar.Open)
OpenPosition(PositionType.Long, OrderType.Market);

How do I do a Crossover/Crossunder using SystemUtils if I want to test the crossover/under using the QQQQ data but executing orders on another symbol?

In other words, how do I incorporate the OtherSymbols property into the "if (SystemUtils.CrossOver(SMA50, SMA200) statement?

Thanks in advance

Posted Thursday May 14 2015

The OtherSymbols property gives you access to the "SymbolScript" objects for other symbols.  So you can access any public member of your SymbolScript class.  To check for a crossover, you could do something like this:
if (SystemUtils.CrossOver(OtherSymbols["QQQQ"].SMA50, OtherSymbols["QQQQ"].SMA200))
    // ...

Posted Friday July 24 2015
I had the same question as ywlee but now I'm running into another problem. What if I want to open a position if
  1. a symbol's closing price crosses its SMA200 
  2. and QQQQ close is trading above a SMA200.
In other words, if QQQQ is below its SMA200 I don't want to execute any buys.

I've got the code for #1 but can't figure out how to put it all together.


Edited: Friday July 24 2015 by pincheblake
Posted Friday July 24 2015
It would be something like this:

if (SystemUtils.CrossOver(Close, SMA200) &&
    OtherSymbols["QQQQ"].Close.Current > OtherSymbols.SMA200.Current)
  // ...

Posted Wednesday July 29 2015
Thanks for the help. I've run into another problem that I haven't been able to solve on my own. Any ideas?
Posted Friday August 21 2015
A related question on OtherSymbols:

a/ I used OtherSymbols["GOOG"] to get a DivideSeries() result with Symbol.Name "MSFT" (per the example in the manual)
b/ Later on in the code I want to exclude MSFT but only execute "GOOG" if the DivideSeries has a certain value and other times to exclude "GOOG" but only execute "MSFT" if the DivideSeries has a certain value.

c/ I have tried using (If Symbol.Name == "GOOG") to reference GOOD but each time the code only executes for the MSFT portion of the code.  All code that refers to "GOOG" does not execute.

I'm using PositionSettings to execute the code so not sure if there is a control in PositionSettings to selec the Symbol by Name.  Have tried positionsettings.Symbol.Name = "GOOG" but that returns an error.

THanks in advance. 

Similar Topics

Reading This Topic

2005-2018 © RightEdge Systems