Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
need help :: cant fix :: Object reference not set to an instance of an object
I have a strategy I have been building, and there is an error that logs when I try a Strategy Analyzer backtest (NT 6.5.16). """Error on calling the 'OnBarUpdate' method for indicator ...: Object reference not set to an instance of an object., """
I tried to make the code down to base essential, and also used the Strategy Wizard, but I get the same error. The strategy compiles ok, and actually does output on chart and take trades on historical data.
I have even requested minimum 2000 bars of data to start the backtest with no difference in error in log. The error has made crazy me for the whole day. I would appreciate a fix for the code if anyone would please assist.
The basic stratagy is attached, exported from NT 6.5. The code I am trying to use is real simple, I can comment out either one of the two SuperTrend conditions and have the same error in log. My preference is to use the second line where ..Value == true, the other was to test the Strategy Wizard code:
If anyone can assist it would be extremely helpful, and I will bless you in my prayers !!
Trader.Jon
Can you help answer these questions from other members on NexusFi?
I'm guessing based on the code you posted (I don't have time to really examine or test it at the moment). My guess is that .MaUpTrend is a series that doesn't always have a value defined, and you're trying to test for that because the error your getting must be what Ninja gives if the value is undefined.
Try putting the .ContainsValue test first. For details google "short circuit evaluation".
Thanks for that suggestion ... I did try both methods separately before combining the code and had the same errors each way. Sorry that I wasnt more explicit about that in my explanation.
Tried your suggest ... even restarted NT first to clear out anything in the cache .. still same error ..
Also tried it without that .MaUp/DownTrend in the line and still get the same error :
(( SuperTrendRetracement(Typical, 20, 20, 14, 2.618, 3, 3)[0] < Typical[0]))
Well, I'm a little stumped here. I'm willing to keep working on it if someone can tell me in English what SuperTrendRetracement is supposed to do. The comments are in Spanish, so they don't help me. And the code (in the version in the posted AFix.zip) has some problems. The 'diff' DataSeries and the HullMovingAverage of same serve no purpose, but I assume they were intended to.
On the chart I'm using for testing the final bar is returning an 'UpTrend' of 0, even though the SuperTrend UpTrend value for the same bar is valid, I really can't see why, I'm even beginning to suspect some kind of NT7 bug (but I wouldn't say so yet).
I think my next approach would be to reimplement it from scratch if I understood exactly what it's supposed to do.
I revisited the SuperTrend thread in NT Forums and found the indicator posting: he is from Italy. My visual on the indicator is that it draws out arrows at retracement points (hopefully) giving re-entry points in direction of the overall trend. ..OR .. it can guesstimate that the trend hasnt reversed yet and we are getting out of chop. Cant say for sure that the arrows are too late to matter yet or not.
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Trading: FDAX, cable/yen, FX, options on commodities
Posts: 67 since Jun 2009
Thanks Given: 16
Thanks Received: 10
Hi Jon,
Would the code to enter long if the overall direction of supertrend is up look like the following? Not a crossover signal, just confirm that the general direction is bullish.
protected override void OnBarUpdate() { // Condition set 1 if ( Close[1] > Open[1] && (SuperTrend(10, 3).UpTrend[0]) )
{ EnterLong(DefaultQuantity, "");}
Would the reverse hold true for a short entry?
(!SuperTrend(10, 3).UpTrend[0])
I'd like to test code that goes long/short after an initial signal which will then also check the supertrend to verify if it is up/down.
Would the code to enter long if the overall direction of supertrend is up look like the following? Not a crossover signal, just confirm that the general direction is bullish.
protected override void OnBarUpdate() {
// Condition set 1
if (
Close[1] > Open[1]
&& (SuperTrend(10, 3).UpTrend[0])
)
{
EnterLong(DefaultQuantity, "");}
Would the reverse hold true for a short entry?
(!SuperTrend(10, 3).UpTrend[0])
I'd like to test code that goes long/short after an initial signal which will then also check the supertrend to verify if it is up/down.
On glance, I think that would work.. I use TS_SuperTrend for strategy input.