Profile Picture

Referencing other symbols

Posted By Steve2008 8 Years Ago
Message
Posted Tuesday February 10 2009
1. Within a trading system operating on a multi-symbol portfolio, e.g., the S&P 500 component stocks, how can I do something like take the ATR of an index or ETF, e.g., SPY? For efficiency, this should be done only once per bar, rather than once for each symbol -- 500 times. The calculation would need to be done prior to the other calculations for the first symbol, and persist in memory for access in calculations for all symbols.

2. Is there a way to do the above on a different timeframe, for example, a daily ATR of an index in a trading system operating on 1 minute bars?

3. Can RE be made to take a trade on a symbol that is not the current symbol list, or alternatively, quickly add a new symbol to the current list and then take a trade on it?

Posted Wednesday February 11 2009
1. Yes, you can do this.  Add the index to your symbol list like normal, but special case that symbol in your symbol script to do no trades and to calculate the indicators you want on the index.  Override the system NewBar method to run the symbol script NewBar for the index before the other symbols, like this:

 

public override void NewBar()

{

      Symbol indexSymbol = SystemData.GetSymbolByName("QQQQ");

     

      //    Call NewBar for index symbol

      SymbolScripts[indexSymbol].NewBar();

 

      //    Call NewBar for the rest of the symbols

      foreach (MySymbolScript ss in SymbolScripts)

      {

            if (ss.Symbol != indexSymbol)

            {

                  ss.NewBar();

            }

      }

}

Then you can access the index indicators from other symbols by referring to OtherSymbols[indexSymbol].IndicatorName.

2. This is one of the main features of RE2008E2.  See the guide in this post for details.

3. No.  There is a request for this on the uservoice forum you can vote on.

Thanks,
Daniel

Posted Thursday February 12 2009
Thanks, I will try this, and general thanks to RE staff for the support you provide.
Posted Thursday November 04 2010
@dplaisted

Hello,

I'm trying to do the same (index processing first), but using NewTick method (after setting SystemData.CreateTicksFromBars to true).
Unfortunately the simple transcription of the above NewBar metod does not the trick, because I cannot get tick and partialbar instances, corresponding to the index symbol.
Any help very appreciated.

Pawel
Posted Thursday November 04 2010
You can reference the partial bar of any symbol through the bar lists: SystemData.Bars[symbol].PartialItem.

However, ticks are not processed quite the same way as bars. When a new bar is generated, it is generated for all symbols (for the same frequency).

However, ticks are processed one by one. So there's no such thing as a current tick for the other symbols. You could save the most recent tick for each symbol in NewTick, but there would be no guarantee what time that tick would be from. When CreateTicksFromBars is true, each bar is broken into 4 ticks (for the open, low, high, and close). But the order they are processed in between the symbols is arbitrary. So when you get the low tick for one symbol, you don't know whether the most recent tick for another symbol is going to be the low or the open.

Thanks,
Daniel


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems