Profile Picture

Working with Multiple Symbols

Posted By rekab 6 Years Ago
Message
Posted Thursday December 29 2011
Can anyone tell me why this throws an error:
public override void Startup()
{
   SMA = new SMA(10);
   SMA.SetInputs(OtherSymbols["MSFT"].Close);
}

ERROR:

An exception of type System.ArgumentOutOfRangeException was thrown.
Value must be between 0 and -1, value was 0
Parameter name: nBars
at RightEdge.Common.RList`1.LookBack(Int32 nBars)
at RightEdge.Common.BarElementSeries.LookBack(Int32 nBars)
at RightEdge.Common.SeriesCalculatorBaseWithValues.NewBar()
at RightEdge.Common.IndicatorManager.NewBar(FrequencyNewBarEventArgs args)
at RightEdge.Common.Internal.SystemRunner.UpdateObjects(FrequencyNewBarEventArgs args)
at RightEdge.Common.Internal.SystemRunner.ProcessBarEvents(IEnumerable`1 eventList)
at RightEdge.Common.FrequencyManager.SendPendingBars()
at RightEdge.Common.FrequencyManager.UpdateTime(DateTime dateTime)
at RightEdge.Common.Internal.SystemRunner._tickGenerator_NewBar(Object sender, NewBarEventArgs e)
at RightEdge.Common.TickGenerator.ProcessBar(NewBarEventArgs args)
at RightEdge.Common.Internal.SystemRunner.ProcessBar(NewBarEventArgs newBars)
at RightEdge.Shared.SystemWrapper.RunSystem(SystemData systemData, SharedSystemRunData runData, ServiceFactory brokerFactory)
at RightEdge.Shared.SystemWrapper.RunSystem(String filename, ServiceFactory brokerFactory, PluginSettings dataStoreSettings)
at RightEdge.Shared.SystemWrapper.RunSystem(String filename, ServiceFactory brokerFactory, PluginSettings dataStoreSettings)
at RightEdge.Shared.TradingModuleWrapper.Run(String filename)
at RightEdge.Shared.TradingModuleWrapper.RunSystem(SharedSystemRunData systemRunData)
at RightEdge.SystemProgress.InitAndRunSystem()

Help please.

Thanks!

: )
Posted Friday December 30 2011
Really stumped here. -- Any help would be greatly appreciated.

I must be doing something REALLY silly, because it can't be that hard to reference a simple moving average of symbol.

Thanks!

: )
Posted Friday December 30 2011
So...

I moved:
SMA = new SMA(10);
SMA.SetInputs(OtherSymbols["MSFT"].Close);
...into NewBar() which makes more sense because there's no bar data on startup, but I still get a System.ArgumentOutOfRangeException. I've tried adding if (Bars.Count <= 10) return; to NewBar(), but that doesn't help either.

At this point, I have no idea what I'm doing wrong. I want to reference the SMA of a symbol (MSFT) in my trading logic. Something like: If the close is less than the SMA of MSFT, place an order.

How do I do that?!?

Thanks in advance for your help!!!

: )
Posted Friday December 30 2011
Just to be 100% clear about what I'm trying to do, this:
public override void NewBar()
{
   SMA = new SMA(10);
   SMA.SetInputs(OtherSymbols["MSFT"].Close);
   
   if (OtherSymbols["MSFT"].Close.Current > SMA.Current)
   {
      PositionSettings settings = new PositionSettings();
      settings.PositionType = PositionType.Long;
      settings.OrderType = OrderType.Market;
   
      Position position = OpenPosition(settings);
      if (position.Error != null)
      {
         OutputWarning(position.Error);
      }
   }
}
produces a System.ArgumentOutOfRangeException error

Can anyone help me understand why?

Thanks!

: )
Posted Friday December 30 2011
Sorry, this is a bug. Thanks for reporting it. It should be fixed in the next build.

The bug happens when you use a bar element (ie the Open, Close, High, Low, etc) from one symbol as an input to an indicator for another symbol. If the input is an indicator instead of a raw bar element it should work. Also, for your case it looks like you could just have the SMA's input be the Close of the current symbol (instead of MSFT's close), and then you could refer to MSFT's SMA. Ie use OtherSymbols["MSFT"].SMA.Current instead of just SMA.Current.

Thanks,
Daniel
Posted Friday December 30 2011
Thanks Daniel!

Per your suggestion, I'll use OtherSymbols["MSFT"].SMA.Current as a work around until this gets fixed.


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems