Does the exception have to do with using multiple indicators with a combination different calculation types going to work for doing analysis and backtesting?
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
'OnBarUpdate' method on bar 3: Object reference not set to an instance of an object.
Collapse
X
-
'OnBarUpdate' method on bar 3: Object reference not set to an instance of an object.
The strategy will run, but when using the Strategy Analyzer for optimizing or backtesting an exception error occurs. pjsHeikenAshi Histogram indicator for Delta Mode uses OnPriceChange Close[0] - Open[0] to get the values that indicator that is needs to measure the Delta change. EMA820 uses OnBarClose for the type of calcuation
Does the exception have to do with using multiple indicators with a combination different calculation types going to work for doing analysis and backtesting?Tags: None
-
Hello Tonofit,
Where you have mentioned:
"a combination different calculation types"
This is not allowed for hosted indicators. Any indicator called by a strategy (or other host indicator) must be using the same calculation mode.
Use Calculate.OnEachTick so this will satisfy host and hosted dependents, and code the scripts that need to trigger actions when the bar closes with IsFirstTickOfBar.
Use TickReplay in historical, should you want this to update properly in historical data.
The error is that barsAgo index is invalid. Meaning that indicator may not have a value yet.
Try using if (CurrentBars[0] < 2) return;
(Or is this a script locked for editing in the Strategy Builder? In which case the indicator code needs to be corrected)Chelsea B.NinjaTrader Customer Service
-
I changed the strategy to use Calculate.OnEachTick and added a data series of native Ticks,but one of the histograms needs to use Calculate.OnPriceChange. When the strategy starts I'm using variables that act as signals to control that only a single trade occurs with OnBarUpdate. How should I setup the initalization so the variables are set to false when real-time occurs?
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by DJ888, Yesterday, 10:57 PM
|
0 responses
6 views
0 likes
|
Last Post
by DJ888
Yesterday, 10:57 PM
|
||
Started by MacDad, 02-25-2024, 11:48 PM
|
7 responses
158 views
0 likes
|
Last Post Yesterday, 10:23 PM | ||
Started by Belfortbucks, Yesterday, 09:29 PM
|
0 responses
7 views
0 likes
|
Last Post
by Belfortbucks
Yesterday, 09:29 PM
|
||
Started by zstheorist, Yesterday, 07:52 PM
|
0 responses
7 views
0 likes
|
Last Post
by zstheorist
Yesterday, 07:52 PM
|
||
Started by pmachiraju, 11-01-2023, 04:46 AM
|
8 responses
151 views
0 likes
|
Last Post
by rehmans
Yesterday, 06:44 PM
|
Comment