External Symbol - Plotting and Using
Author: innertrader
Creation Date: 2/9/2017 5:03 AM
profile picture

innertrader

#1
I would like to add an External Symbol value as an additional condition in a trading strategy. First, I am trying to plot the series, but it gives me the Primary Symbol plot in the new pane instead of the External Symbol. Here is the code:

CODE:
Please log in to see this code.


Once this is working I want to use the daily External Symbol value as part of trading rule. Would I do this like this?
CODE:
Please log in to see this code.


Do I need to use ChangeContext( ) anywhere if I only want to trade the Primary Symbol, not the External Symbol?
profile picture

Eugene

#2
1 -
CODE:
Please log in to see this code.


2 - No, you don't have to use Set/RestoreContext.
profile picture

innertrader

#3
I had that previously, but it generates the following error:

QUOTE:
Run time error. Object reference not set to an instance of an object.
profile picture

Eugene

#4
Look, you can not have it other than "vix.Close" if you want to plot the secondary symbol's series. Having a runtime error is not a good reason to break the correct syntax.

Ideas to try:

1) Use Synchronize()
2) Call GetExternalSymbol() without dataSetName
3) More troubleshooting suggestions in the Wiki > Errors | Strategy > Object reference not set to an instance of an object

profile picture

innertrader

#5
I pursued idea #3 and figured out my DataSetName variable had an incorrect capitalization the name. That was causing it.

Thanks.
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).