Indi works on chart, not in Market Analyzer. Null ref check? - NinjaTrader Programming | futures io social day trading
futures io futures trading


Indi works on chart, not in Market Analyzer. Null ref check?
Updated: Views / Replies:2,100 / 5
Created: by MXASJ 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
 

Indi works on chart, not in Market Analyzer. Null ref check?

  #1 (permalink)
Elite Member
Asia
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 786 received

Indi works on chart, not in Market Analyzer. Null ref check?

Guys this one has me scratching my head. Here is the guts of a simple indicator that takes today's Highs and Lows from IQFeed and plots them on a chart:

 
Code
protectedoverridevoid Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Violet), PlotStyle.Line, "MyHi"));
Add(new Plot(Color.FromKnownColor(KnownColor.LightSkyBlue), PlotStyle.Line, "MyLo"));
Overlay = true;
}
///<summary>
/// Called on each bar update event (incoming tick)
///</summary>
protectedoverridevoid OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
MyHi.Set(MarketData.DailyHigh.Price);
MyLo.Set(MarketData.DailyLow.Price);
}
Nothing special, no errors. But when I try to use that indicator in Market Analyzer, I get the "Object reference not set to an instance of an object." error. Specifically:


Quoting 
Error on calling 'OnBarUpdate' method for indicator 'MyHiLoPlots' on bar 0: Object reference not set to an instance of an object.

I am sure I am missing something simple like a null ref check. Any suggestions?

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
Asia
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 786 received


Also tried this. No joy:

 
Code
protectedoverridevoid OnBarUpdate()
{
// Use this method for calculating your indicator values. Assign a value to each
// plot below by replacing 'Close[0]' with your own formula.
double lo = MarketData.DailyLow.Price;
double hi = MarketData.DailyHigh.Price;

if (hi != null) MyHi.Set(hi);
if (lo != null) MyLo.Set(lo);
}

Reply With Quote
 
  #4 (permalink)
Elite Member
Denver, CO
 
Futures Experience: Advanced
Platform: NinjaTrader
Broker/Data: NinjaTrader Brokerage
Favorite Futures: ES
 
NinjaTrader's Avatar
 
Posts: 1,260 since May 2010
Thanks: 153 given, 1,890 received

MXASJ,

The reason MarketData doesn’t work in the Market Analyzer is because this unsupported property is specifically programmed in a manner to be for charts only. To work around this you could try using these other unsupported properties: e.MarketData.DailyHigh.Price and e.MarketData.DailyLow.Price in the OnMarketData() method. Using it this way will only be applicable to real-time data going forward though.

Please find an attached sample of this combining both worlds with use of MarketData for the historical points on the chart, and the OnMarketData() usage for real-time and the Market Analyzer.

Attached Files
Register to download File Type: zip DailyHighLow.zip (1.8 KB, 34 views)
Reply With Quote
The following 2 users say Thank You to NinjaTrader for this post:
 
  #5 (permalink)
Elite Member
Asia
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 786 received

Thanks Ray. The use of if(Historical) is a good idea for charting, but that code still does not work on both a Chart and in Market Analyzer.

My end game is some additional code I'm working on for the MarketAnalyzerTools indicator I started here: https://futures.io/ninjatrader-programming/10558-session-hilo-audio-alerts-beta.html

At present the user of that indicator gets his daily High and Low data via calculations done in Ninja that are reliant on Session Templates, and then an equivalence check is run to see if we are trading at the High or Low (if(Close[0]==DailyHigh[0]), for example) so you get an audio and/or visual alert in Market Analyzer.

I'm trying to add the option to use vendor-provided High/Low data instead of Ninja calculated High/Low data.

I think I need to functional equivalent of the GetCurrentBid() method, but where e.MarketData is DailyHigh or DailyLow. That could then be called in OnBarUpdate().

I'll dig out the C# book and have a look at creating two Custom methods, GetDailyHigh() and GetDailyLow().

If anyone thinks I'm approaching this the hard way I'm open to input! Thanks.

Reply With Quote
 
  #6 (permalink)
Elite Member
Asia
 
Futures Experience: Beginner
Platform: NinjaTrader, TOS
 
Posts: 798 since Jun 2009
Thanks: 109 given, 786 received

This appears to work for my purposes and doesn't throw exceptions when used in Market Analyzer:

 
Code
protectedoverridevoid OnBarUpdate()
{
}
protectedoverridevoid OnMarketData(MarketDataEventArgs e)
{
if (e.MarketData.DailyHigh != null)
Plot0.Set(e.MarketData.DailyHigh.Price);

if (e.MarketData.DailyLow != null)
Plot1.Set(e.MarketData.DailyLow.Price);
}
I'll update the code in the other thread after a few more hours of testing. The High/Low alerts in Market Analyzer can now come from either Ninja calculated data or vendor provided data.

Reply With Quote

Reply



futures io > > > > > Indi works on chart, not in Market Analyzer. Null ref check?

Thread Tools Search this Thread
Search this Thread:

Advanced Search



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

Linda Bradford Raschke: Reading The Tape

Elite only

Adam Grimes: TBA

Elite only

NinjaTrader: TBA

January

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
MSA - Market System Analyzer (www.adaptrade.com) PandaWarrior Trading Reviews and Vendors 19 November 17th, 2013 10:47 AM
Gomi CD in Market Analyzer cpi65 The Elite Circle 2 May 21st, 2013 05:19 PM
Market Analyzer Indicators to Summarize Chart Indicators nirajkrishna The Elite Circle 5 March 18th, 2011 08:13 PM
How the Stock Market Works Mickey Caine Off-Topic 1 November 15th, 2010 07:20 AM
How to check which indicators are in a NT chart-template-file max-td Beginners and Introductions 2 June 17th, 2010 11:58 AM


All times are GMT -4. The time now is 07:43 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-11 in 0.16 seconds with 20 queries on phoenix via your IP 54.226.132.197