Strategy Monitor - GetExternalSymbol exception
Author: MarkStaunton
Creation Date: 4/25/2010 9:48 AM
profile picture

MarkStaunton

#1
I have a strategy that uses the GetExternalSymbol method. It works in backtesting, however doesnt generate any alerts when run from strategy monitor. Debugging the code when run from the strategy monitor shows the Bars object is not set by the GetExternalSymbols method (null), thus throwing an "Object reference not set to an instance of an object" exception .

I see there are similar posts regarding Strategy Monitor not generating alerts, and in some of the cases the GetExternalSymbols method is also being used in the code. Is there a fix/ work around?

profile picture

Eugene

#2
What is your data provider? Are we talking about accessing the data from a different provider, or the Bars object loaded by GetExternalSymbol belongs to the same provider? Also, what is the time frame and would you mind posting a relevant code snippet?
profile picture

MarkStaunton

#3
Data provider: Y!. I am trying to accessing data from the same provider, however it is in a different dataset ("Indices"). Timeframe is daily.

CODE:
Please log in to see this code.


SP500 object set to null after method is called (when run from strategy monitor). SP500 object set to ^GSPC bars (when run from back test).
profile picture

Eugene

#4
There is a live bug (WL5.6) in GetExternalSymbol when you're using the DataSet overload for the external symbol (like in your synthax). So it's a good idea to not use it when possible.

Since you're using the same data provider, you might want to simplify this; does this help?
CODE:
Please log in to see this code.

profile picture

MarkStaunton

#5
Yes it works when the Dataset overload is removed. However loading the external symbol for every symbol in a dataset increases the strategy monitor scan time considerably. Looks like I'll have to load the external symbol into global memory on the first symbol of the dataset and access it from there. Thanks for the help.
profile picture

Eugene

#6
Good. Sounds like you've found your way, but to anyone interested, here's how:

WealthScript Techniques | Executing some code only once
profile picture

MarkStaunton

#7
This code will execute once on a dataset and will still execute when run against any symbol in a dataset. (ie. it is not dependent on being triggered by the first symbol in a dataset).

CODE:
Please log in to see this code.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).