Profile Picture

Global dictionary

Posted By phg 3 Years Ago
Message
phg
Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)
Posted Saturday February 22 2014
I am trying to define a single, system-wide (shared) dictionary of queues and then initialize each entry (per symbol) in the MySymbolScript constructor thus:

public class MySystem : MySystemBase
{
   public Dictionary> fillAction = new Dictionary>();
   ....
   public class MySymbolScript : MySymbolScriptBase
{
.............
   public MySymbolScript()      // Constructor
   {
      fillAction[Symbol.Name] = new Queue(); // **ERROR** 'fillAction' does not exist in current context
..............

I'd appreciate being pointed in the right direction. ('fillAction' also does not exist under NewBar or the OrderFilled event either.) The dictionary must be global, that is shared by the symbol scripts for each symbol.

-Pete

See also Yahoo group about applying RE.

phg
Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)
Posted Sunday February 23 2014
I was missing "TradingSystem." to provide context, so this compiles:

TradingSystem.fillAction[Symbol.Name] = new Queue\string\(); // Compiles

However, it fails at runtime with "NullReference ... Object reference not set to an instance of an object." which I think refers to the queue.
What is wrong?

Under MySystem the dictionary is defined this way:
   public Dictionary\string, Queue\string\\ fillAction = new Dictionary\string, Queue\string\\();

(Thank you for help.)
(I'm using '\' because the less-than and great-than symbols are being discarded when the message is posted.)

-Pete

See also Yahoo group about applying RE.


Edited: Sunday February 23 2014 by phg
phg
Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)
Posted Sunday February 23 2014
The below statement compiles within the MySymbolScript constructor
TradingSystem.fillAction[Symbol.Name] = new Queue\string\(); // Compiles
But fails at runtime on a NullReference. The following also fails similarly
   if(Symbol.Name == "HYLD"){         // Not valid in the constructor (?)
The common culprit is Symbol.Name which is apparently not initialized at that point?

How can I get the string value of the 'current' symbol?


-Pete

See also Yahoo group about applying RE.


Edited: Sunday February 23 2014 by phg
Posted Sunday February 23 2014
The current symbol isn't available in the SymbolScript constructor. You have to wait until the Startup() method for that information to be available.

Thanks,
Daniel
phg
Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)Supreme Being (44,821 reputation)
Posted Monday February 24 2014
Thanks Daniel. That fixed that.

-Pete

See also Yahoo group about applying RE.



Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems