NexusFi: Find Your Edge


Home Menu

 





Object reference not set to an instance...


Discussion in NinjaTrader

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




 
Search this Thread

Object reference not set to an instance...

  #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?
Build trailing stop for micro index(s)
Psychology and Money Management
New Micros: Ultra 10-Year & Ultra T-Bond -- Live Now
Treasury Notes and Bonds
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Better Renko Gaps
The Elite Circle
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
59 thanks
Funded Trader platforms
36 thanks
NexusFi site changelog and issues/problem reporting
22 thanks
The Program
20 thanks
GFIs1 1 DAX trade per day journal
19 thanks
  #3 (permalink)
 traderwerks   is a Vendor
 
Posts: 692 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: 692 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


© 2024 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 - Privacy Policy - Downloads - Top
no new posts