need help :: cant fix :: Object reference not set to an instance of an object - NinjaTrader Programming | futures io social day trading
futures io futures trading


need help :: cant fix :: Object reference not set to an instance of an object
Updated: Views / Replies:2,752 / 9
Created: by Trader.Jon Attachments:1

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

need help :: cant fix :: Object reference not set to an instance of an object

  #1 (permalink)
Elite Member
Near the BEuTiFULL Horse Shoe
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: MBTrading Dukascopy ZenFire
Favorite Futures: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 176 received

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 tried the suggestion in the NT forums to use the 'try - catch' :
Object reference not set to an instance of an object - NinjaTrader Support Forum
but the output window never prints out my specified statement so I am very frustrated.

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:


 
Code
                            
protected override void OnBarUpdate() {
  
// Condition set 1
  
if (
    
SuperTrendRetracement(Typical2020142.61833).MaUpTrend[0] < Typical[0]
    && 
SuperTrendRetracement(Typical2020142.61833).MaUpTrend.ContainsValue(0) == true)
    {
      
EnterLong(DefaultQuantity"");} 

If anyone can assist it would be extremely helpful, and I will bless you in my prayers !!

Trader.Jon

Attached Files
Register to download File Type: zip AFIX.zip (12.4 KB, 8 views)

Last edited by sam028; July 7th, 2010 at 06:46 PM. Reason: add coding tag
Reply With Quote
 
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

 
  #3 (permalink)
Elite Member
Santa Maria
 
Futures Experience: Advanced
Platform: NinjaTrader, ThinkOrSwim
Broker/Data: Mirus/Zen-Fire
Favorite Futures: ES
 
Posts: 295 since May 2010
Thanks: 101 given, 320 received



Trader.Jon View Post
I have a strategy I have been building, and there is an error ...

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".

 
Code
// Condition set 1
if ( SuperTrendRetracement(Typical, 20, 20, 14, 2.618, 3, 3).MaUpTrend.ContainsValue(0) == true
  && SuperTrendRetracement(Typical, 20, 20, 14, 2.618, 3, 3).MaUpTrend[0] < Typical[0] )
{
   EnterLong(DefaultQuantity, "");
}
// Condition set 2
if ( SuperTrendRetracement(Typical, 20, 20, 14, 2.618, 3, 3).MaDownTrend.ContainsValue(0) == true
  && SuperTrendRetracement(Typical, 20, 20, 14, 2.618, 3, 3).MaDownTrend[0] > Typical[0] )
{
   ExitLong("", "");
}

Reply With Quote
 
  #4 (permalink)
Elite Member
Near the BEuTiFULL Horse Shoe
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: MBTrading Dukascopy ZenFire
Favorite Futures: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 176 received

JHL,

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]))

TJ


Last edited by Trader.Jon; July 7th, 2010 at 07:11 PM. Reason: trying different variations of code
Reply With Quote
 
  #5 (permalink)
Elite Member
Santa Maria
 
Futures Experience: Advanced
Platform: NinjaTrader, ThinkOrSwim
Broker/Data: Mirus/Zen-Fire
Favorite Futures: ES
 
Posts: 295 since May 2010
Thanks: 101 given, 320 received

Still looking at it. Problem's not in your strategy, that's why your catch isn't hit. Problem's in the indicator.

Reply With Quote
The following user says Thank You to fluxsmith for this post:
 
  #6 (permalink)
Elite Member
Santa Maria
 
Futures Experience: Advanced
Platform: NinjaTrader, ThinkOrSwim
Broker/Data: Mirus/Zen-Fire
Favorite Futures: ES
 
Posts: 295 since May 2010
Thanks: 101 given, 320 received

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.

Reply With Quote
 
  #7 (permalink)
Elite Member
Near the BEuTiFULL Horse Shoe
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: MBTrading Dukascopy ZenFire
Favorite Futures: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 176 received

Retracement = ??

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.

The poster doesnt post often, and there is no real discussion of his contribution to give more to go on: Super Trend For Ninja Trader Needed - Page 5 - NinjaTrader Support Forum

Thanks for the effort: I think there are likely better use of our mutual time awaiting us.

Jon


fluxsmith View Post
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.


Reply With Quote
 
  #8 (permalink)
Elite Member
Dublin, Ireland.
 
Futures Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Favorite Futures: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 9 received


Trader.Jon View Post
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 tried the suggestion in the NT forums to use the 'try - catch' :
Object reference not set to an instance of an object - NinjaTrader Support Forum
but the output window never prints out my specified statement so I am very frustrated.

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:


 
Code
                            
protected override void OnBarUpdate() {
  
// Condition set 1
  
if (
    
SuperTrendRetracement(Typical2020142.61833).MaUpTrend[0] < Typical[0]
    && 
SuperTrendRetracement(Typical2020142.61833).MaUpTrend.ContainsValue(0) == true)
    {
      
EnterLong(DefaultQuantity"");} 
If anyone can assist it would be extremely helpful, and I will bless you in my prayers !!

Trader.Jon

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.


 
Code
                            
protected override void OnBarUpdate() {
  
// Condition set 1
  
if (
    
Close[1] > Open[1
   && (
SuperTrend(103).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.

Reply With Quote
 
  #9 (permalink)
Elite Member
Near the BEuTiFULL Horse Shoe
 
Futures Experience: Beginner
Platform: NinjaTrader
Broker/Data: MBTrading Dukascopy ZenFire
Favorite Futures: $EURUSD when it is trending
 
Trader.Jon's Avatar
 
Posts: 500 since Jul 2009
Thanks: 401 given, 176 received


mrticks View Post
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.


 
Code
                            
protected override void OnBarUpdate() {

  
// Condition set 1
  
if (
    
Close[1] > Open[1
   && (
SuperTrend(103).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.

Jon

Reply With Quote
 
  #10 (permalink)
Elite Member
Dublin, Ireland.
 
Futures Experience: Advanced
Platform: NinjaTrader, TOS, Multicharts, Open Source various
Favorite Futures: FDAX, cable/yen, FX, options on commodities
 
mrticks's Avatar
 
Posts: 67 since Jun 2009
Thanks: 16 given, 9 received



Trader.Jon View Post
On glance, I think that would work.. I use TS_SuperTrend for strategy input.

Jon

Thanks Jon.

Reply With Quote

Reply



futures io > > > > > need help :: cant fix :: Object reference not set to an instance of an object

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error: Object reference not set to an instance of an object. gomad NinjaTrader Programming 11 December 22nd, 2014 09:09 AM
object name ? sam028 NinjaTrader Programming 3 March 14th, 2011 10:55 AM
ninja trader object reference not set to an instance kk240 NinjaTrader Programming 4 December 29th, 2010 11:16 AM
Object reference not set to an instance... dsraider NinjaTrader Programming 5 July 30th, 2010 09:17 AM
EasyLanguage Object Reference philloo TradeStation 2 June 18th, 2010 03:56 AM


All times are GMT -4. The time now is 02:17 AM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-14 in 0.16 seconds with 20 queries on phoenix via your IP 54.221.76.68