GetExternalSymbol throws "Object reference not set to an instance of an object" in Strategy Monitor
Author: spikemc
Creation Date: 3/5/2016 9:06 PM
profile picture

spikemc

#1
Hello I make a dataset with 2 US stocks (BAC - AAPL)
And I make this really easy code to find a problem with GetExternalSymbol that I have when I execute it with the Strategy Monitor on this 2 stocks DataSet

The code buys when the last bar close is over 50. Nothing else.
Close[Bars.Count - 1]>50

But I want to use GetExternalSymbol calling diferent references depending on the stock included in the dataset and the problem is really the same.
I know EURNOK (Euro / Norwegian Krone) Daily Close is over 5 now.
I Know EURUSD (Euro/ US dollar) Daily Close is less than 5 now.


So I want buy AAPL which Daily Close >10 and don4t buy BAC which Daily Close<10 and make this code for screener:


CODE:
Please log in to see this code.




If I execute the screener with the Strategy Monitor choosing a single Stocks it works

I select AAPL from the Dataset ----Buy. Perfect!!!!
I select BAC from the Dataset------- Don't Buy. Perfect!!!!

I select the DataSet with the 2 stocks (BAC - AAPL)
And it does not work and I have an error: Object reference not set to an instance of an object

Of course, I have the the historical prices for AAPL, BAC, EURUSD, EURNOK
In fact, if I select a only one stock for the Strategy Monitor it works fine, if I select the DataSet, I have the error.

With the GetExternalSymbol, sometimes I need to choose EURNOK and sometimes I need to choose EURUSD depending on the stock I have included in the dataset , but it doesnt work when I select a multisymbol dataset on the Strategy Monitor



profile picture

Eugene

#2
Hola,

I ran your innocuous code several times in MSB mode on DataSets that belong to different providers (so that the external symbols may belong to the same or an external DataSet) and found no error. Check this out, first paragraph, maybe this gives a hint about some other part of your code?

Object reference not set to an instance of an object

P.S. On a related note, beware of running "screener" scripts in Strategy Monitor if they intend to exit positions: IsLastPositionActive remains false in Strategy Monitor
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).