NexusFi: Find Your Edge


Home Menu

 





Object reference not set to an instance...


Discussion in NinjaTrader

Updated
    1. trending_up 4,125 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 5 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
dsraider
New York, NY
 
Posts: 142 since Dec 2009
Thanks Given: 41
Thanks Received: 87

So, I created a painfully simple strat which utilizes nothing but the RSI. When I went to run it on my chart, I got this in the log: Error on calling 'OnBarUpdate' method for strategy 'MyStrategy': Object reference not set to an instance of an object.

I read somewhere that this had to do with nulls BUT here's my code:

 
Code
                            
if (entryOrder1 == null && RSI(71)[1] <= 30 && RSI(71)[0] > 30)        
    {
    
entryOrder1 EnterLong(DefaultQuantity"MyStrategy");
         } 
Opposite for shorts (using the 70 line).

It doesn't get much simpler than that. Also, after doing this, another one of my strats, with which I've never had a problem, starting throwing the same error. Does anyone know if anything else might be causing this? It's just plain weird.

Thanks,
Dave


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Kharg Island at 6%, Regime Fall at 1.5% -- The Black Swa …
Prediction Markets & Event Contracts
Victory Day Delivers: Russia-Ukraine Ceasefire Market Cl …
Prediction Markets & Event Contracts
SEC Chairman Calls for New Golden Age of SEC-CFTC Regula …
Traders Hideout
Asia Equities Crash Overnight -- Nikkei -5.2%, KOSPI -6. …
Traders Hideout
NinjaTrader Connect Launches -- Krakens $1.5B Acquisitio …
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
22 thanks
2026 Jlab journal
10 thanks
Trying to learn Volume and price action correlation
8 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Hello Im new here
5 thanks
  #3 (permalink)
 traderwerks   is a Vendor
 
Posts: 688 since Jun 2009
Thanks Given: 436
Thanks Received: 465



dsraider View Post
So, I created a painfully simple strat which utilizes nothing but the RSI. When I went to run it on my chart, I got this in the log: Error on calling 'OnBarUpdate' method for strategy 'MyStrategy': Object reference not set to an instance of an object.

I read somewhere that this had to do with nulls BUT here's my code:

 
Code
                            
if (entryOrder1 == null && RSI(71)[1] <= 30 && RSI(71)[0] > 30)        

    {
    
entryOrder1 EnterLong(DefaultQuantity"MyStrategy");
         } 

Thanks,
Dave

Nothing weird about it. Just look at you code at think about the sequence that things happen when your strat runs.


Reply With Quote
  #4 (permalink)
dsraider
New York, NY
 
Posts: 142 since Dec 2009
Thanks Given: 41
Thanks Received: 87

Thanks for your reply, traderwerks. Anymore detail on that, though? I haven't done anything different with this one than normal and I definitely don't understand why a strat that's been working perfectly for months suddenly throws an error message every time I try and load it.

Thanks again,
Dave


Reply With Quote
  #5 (permalink)
 traderwerks   is a Vendor
 
Posts: 688 since Jun 2009
Thanks Given: 436
Thanks Received: 465


dsraider View Post
Thanks for your reply, traderwerks. Anymore detail on that, though? I haven't done anything different with this one than normal and I definitely don't understand why a strat that's been working perfectly for months suddenly throws an error message every time I try and load it.

Thanks again,
Dave

I cannot tell you exactly because I just saw a code snippet. Whatever the problem is , just watch what you are doing with the entryOrder. Just walk through the Code and e answer should pop out.


Reply With Quote
  #6 (permalink)
dsraider
New York, NY
 
Posts: 142 since Dec 2009
Thanks Given: 41
Thanks Received: 87

It was a (bad word here) Draw object.

Thanks for your help.

Dave


Reply With Quote




Last Updated on July 30, 2010


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts