Problem with OnMarketData() - NinjaTrader Programming | futures io social day trading
futures io futures trading


Problem with OnMarketData()
Updated: Views / Replies:3,789 / 35
Created: by ketron82 Attachments:0

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
 

Problem with OnMarketData()

  #11 (permalink)
Trading Apprentice
Rome Italy
 
Futures Experience: Intermediate
Platform: MarketDelta
Favorite Futures: EUR/USD
 
Posts: 27 since Feb 2012
Thanks: 7 given, 4 received

I add this class at moment but I come from C++ and I I'm encountering some problems with Ninja "C"
Is ok?

P.s. For the moment I don't want to order row by price but only create rows that store price and relative TOTAL bid x ask vol

Es.
## 1.3500 130 110 ##
## 1.3501 102 85 ##
ecc.ecc

 
Code
    #region Variables
        // Wizard generated variables
        // User defined variables (add any user defined variables below)

		
		static private double askPrice = 0;
		static private double bidPrice = 0;
		static private double upVol = 0;
		static private double downVol = 0;
		static private double neutralVol = 0;
		static private double totalVol = 0;
		
		private	List<Row>		Rows = new List<Row>();
		
		#endregion

		private class Row
		{
			
			public	double	Price;
			public	double	AskVol;
			public  double  BidVol;

			public Row(double myPrice, double myAsk, double myBid)
			{
				Price	    = myPrice;
				AskVol		= myAsk;
				BidVol		= myBid;
			}
		}


Last edited by ketron82; October 11th, 2013 at 01:46 PM.
Reply With Quote
 
  #12 (permalink)
Elite Member
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 3,336 since Dec 2012
Thanks: 11,276 given, 7,090 received


ketron82 View Post
I add this class at moment but I come from C++ and I I'm encountering some problems with Ninja "C"
Is ok?

NinjaScript is C# not C++ so if you are serious about development I recommend you study the NinjaScript reference manual, and the many online tutorials that Google will throw up.

For your particular track I would recommend looking at the code for the Ninja built-in VolumeProfiles indicator, it uses sorted dictionaries to accomplish what I think you look for. I have used it as a basis to build simple multi-pane profiles and rolling profiles myself. You should also find a lot of other great work here on futures.io (formerly BMT) already, but I know how satisfying it is to get under the hood yourself!

Cheers

Travel Well
Reply With Quote
The following user says Thank You to ratfink for this post:
 
  #13 (permalink)
Trading Apprentice
Rome Italy
 
Futures Experience: Intermediate
Platform: MarketDelta
Favorite Futures: EUR/USD
 
Posts: 27 since Feb 2012
Thanks: 7 given, 4 received



ratfink View Post
NinjaScript is C# not C++ so if you are serious about development I recommend you study the NinjaScript reference manual, and the many online tutorials that Google will throw up.

For your particular track I would recommend looking at the code for the Ninja built-in VolumeProfiles indicator, it uses sorted dictionaries to accomplish what I think you look for. I have used it as a basis to build simple multi-pane profiles and rolling profiles myself. You should also find a lot of other great work here on futures.io (formerly BMT) already, but I know how satisfying it is to get under the hood yourself!

Cheers

Many thanks...Yes C# is not a C++...I use a reference manual but I have to make more experience with the C#...I'm studing!

For now....I think that I will use a DrawRectangle() or similar to draw what I need ....!
I'm using at moment 3 monodimensional array for store ask and bid volume traded for every price but I know that monodimensional array can store only 256 values....so I need to use a Class.
In this moment I only need to test what I want and monodimensional arrays working good in intraday (more of 256 points at day is very hard for every classic instrument like currency or index).
Only trouble regarde the delay time spent in sorting the arrays. I will use a simple sort or boubble sort or other ( is there a library or function to do that?) and I hope that in this way I will not lose tick under market acceleration.
Any comment is appreciated.

Many thanks and sorry for my english.

Reply With Quote
 
  #14 (permalink)
Elite Member
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 3,336 since Dec 2012
Thanks: 11,276 given, 7,090 received


ketron82 View Post
Only trouble regarde the delay time spent in sorting the arrays. I will use a simple sort or boubble sort or other ( is there a library or function to do that?) and I hope that in this way I will not lose tick under market acceleration.
Any comment is appreciated.

No need to use anything other than the built-in C#/System/.Net SortedDictionary type classes that are used for example in the VolumeProfiles indicator I mentioned, there are many other routes available too.

With regard to performance - on a modern multi-gigahertz cpu you won't even notice it running, in the VolumesProfiles case for example the SortedDictionary is maintained in state on every addition and completely traversed for a full direct redraw every time the custom Plot method is called, but since the latter is at user speed (e.g fractions of seconds not milli or micro seconds) it is effectively invisible.

Have fun!

Travel Well
Reply With Quote
The following user says Thank You to ratfink for this post:
 
  #15 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,477 since Sep 2013
Thanks: 1,698 given, 3,673 received
Forum Reputation: Legendary

Backfill ?

Hello @ratfink

I am on IQfeed

Is there any risk that data comes in, that is back-fill data ?
I thought there was a mechanism, during a spike, when too much data comes, that IQfeed will try to catch
up with the most recent and then later fill in the gap ?

The code seems to build on the fact that data always comes in sequential

Because i am currently on replay data, that will be correct, but i was curious if you had any
experience or comments, in case you run it live and during a spike, when lots of data comes
will that still work correctly ?

Thanks,
Ron

Reply With Quote
 
  #16 (permalink)
Elite Member
Atkinson, NH USA
 
Futures Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker/Data: NinjaTrader Brokerage
Favorite Futures: Futures, CL, ES, ZB
 
NJAMC's Avatar
 
Posts: 1,925 since Dec 2010
Thanks: 2,962 given, 2,294 received


rleplae View Post
Hello @ratfink

I am on IQfeed

Is there any risk that data comes in, that is back-fill data ?
I thought there was a mechanism, during a spike, when too much data comes, that IQfeed will try to catch
up with the most recent and then later fill in the gap ?

The code seems to build on the fact that data always comes in sequential

Because i am currently on replay data, that will be correct, but i was curious if you had any
experience or comments, in case you run it live and during a spike, when lots of data comes
will that still work correctly ?

Thanks,
Ron

Hi @rleplae,

I have not seen back-filling occur on forward testing on Continuum (NT Broker). I do want to caution you as you started working with MTF something that wasn't clear to me. This function will be called for each timeframe. If the instrument is the same for the MTFs you will get multiple calls in a row with the same data, you will need to filter this out. So if you have a 1 Min primary and a 5 min as your 2nd timeframe, you will get two calls to this function. Same with the depth function as well. The BIP flag didn't seem to get updated properly because the instrument is the same for each timeframe. My understanding is it works better for different instruments in a MTF but I haven't tested this yet.

Nil per os
-NJAMC [Generic Programmer]

LOM WIKI: NT-Local-Order-Manager-LOM-Guide
Artificial Bee Colony Optimization
Reply With Quote
The following user says Thank You to NJAMC for this post:
 
  #17 (permalink)
Elite Member
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 3,336 since Dec 2012
Thanks: 11,276 given, 7,090 received


rleplae View Post
Hello @ratfink

I am on IQfeed

Is there any risk that data comes in, that is back-fill data ?
I thought there was a mechanism, during a spike, when too much data comes, that IQfeed will try to catch
up with the most recent and then later fill in the gap ?

The code seems to build on the fact that data always comes in sequential

Because i am currently on replay data, that will be correct, but i was curious if you had any
experience or comments, in case you run it live and during a spike, when lots of data comes
will that still work correctly ?

Thanks,
Ron

Hi Ron, as far as I am aware live data should always be presented in-sequence, any slow down caused by application sloth should be just that, a slowdown at the user presentation level. I do not use IQFeed myself but would be very surprised if they did anything to interfere with sequential trade processing order in low level data handling.

Cheers (i'm awol at the moment but your mention worked, alway sgood to hear from you, I am slowly getting nearer to dropping discretionary playtimes and letting the robots take over..., luckily gardens and mowers have interrupted plans for now.)

Travel Well
Reply With Quote
 
  #18 (permalink)
Elite Member
Birmingham UK
 
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: IG/eSignal
Favorite Futures: Dax
 
ratfink's Avatar
 
Posts: 3,336 since Dec 2012
Thanks: 11,276 given, 7,090 received


NJAMC View Post
Hi @rleplae,

I have not seen back-filling occur on forward testing on Continuum (NT Broker). I do want to caution you as you started working with MTF something that wasn't clear to me. This function will be called for each timeframe. If the instrument is the same for the MTFs you will get multiple calls in a row with the same data, you will need to filter this out. So if you have a 1 Min primary and a 5 min as your 2nd timeframe, you will get two calls to this function. Same with the depth function as well. The BIP flag didn't seem to get updated properly because the instrument is the same for each timeframe. My understanding is it works better for different instruments in a MTF but I haven't tested this yet.

@NJAMC, fwiw I have yet to see BarsInProgress not be updated correctly even in large MTF situations with 30-40 instruments, with or without many of the same instrument with different bar types or timeframes, it just needs care to see what you should see, always remembering of course that you do have to do it the Ninja way. [edit: I will qualify that statement as the evidence is more from OnBarUpdate than from OnMarketData, I do use both heavily and have not seen issues]

Travel Well

Last edited by ratfink; March 18th, 2015 at 11:34 AM.
Reply With Quote
 
  #19 (permalink)
Elite Member
Omer עומר / Israel י
 
Futures Experience: Master
Platform: NinjaTrader, Proprietary,
Broker/Data: Ninjabrokerage/IQfeed + Synthetic datafeed
Favorite Futures: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
 
rleplae's Avatar
 
Posts: 2,477 since Sep 2013
Thanks: 1,698 given, 3,673 received
Forum Reputation: Legendary

walked around


NJAMC View Post
Hi @rleplae,

I have not seen back-filling occur on forward testing on Continuum (NT Broker). I do want to caution you as you started working with MTF something that wasn't clear to me. This function will be called for each timeframe. If the instrument is the same for the MTFs you will get multiple calls in a row with the same data, you will need to filter this out. So if you have a 1 Min primary and a 5 min as your 2nd timeframe, you will get two calls to this function. Same with the depth function as well. The BIP flag didn't seem to get updated properly because the instrument is the same for each timeframe. My understanding is it works better for different instruments in a MTF but I haven't tested this yet.

Hello @NJAMC
I am not running into that issue, because i have 3 charts with 3 strategiess, all mono time-frame but different from each other. the 2 auxiliary strategies post data using JSON to a stand-alone process and the first strategy polls that process (as other stuff is sitting there also that gets pulled in)
but i understand your point...

regards
Ron

Reply With Quote
The following user says Thank You to rleplae for this post:
 
  #20 (permalink)
Elite Member
Atkinson, NH USA
 
Futures Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker/Data: NinjaTrader Brokerage
Favorite Futures: Futures, CL, ES, ZB
 
NJAMC's Avatar
 
Posts: 1,925 since Dec 2010
Thanks: 2,962 given, 2,294 received



ratfink View Post
@NJAMC, fwiw I have yet to see BarsInProgress not be updated correctly even in large MTF situations with 30-40 instruments, with or without many of the same instrument with different bar types or timeframes, it just needs care to see what you should see, always remembering of course that you do have to do it the Ninja way. [edit: I will qualify that statement as the evidence is more from OnBarUpdate than from OnMarketData, I do use both heavily and have not seen issues]

@ratfink,

The issue is not with OnBarUpdate, but with the Data/Depth tick data. Most will not notice the issue, but if you are totaling incoming data, you will get 2X, etc more than expected. The problem only occurs when you have MTF with the same instrument with different time periods. The BIP will not be updated properly on these calls. Different instruments may work fine as that seemed to be the original intent/design of the interface. I have not worked much with different instruments and these low level functions.

Nil per os
-NJAMC [Generic Programmer]

LOM WIKI: NT-Local-Order-Manager-LOM-Guide
Artificial Bee Colony Optimization
Reply With Quote
The following user says Thank You to NJAMC for this post:

Reply



futures io > > > > > Problem with OnMarketData()

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
CalculateOnBarClose = false versus OnMarketData() MWinfrey NinjaTrader Programming 8 September 30th, 2013 01:52 PM
OnMarketData Problem humy65 NinjaTrader Programming 3 October 16th, 2012 11:17 AM
OnMarketData serious issue baberg NinjaTrader Programming 13 September 27th, 2011 10:04 AM
BUG for OnMarketData timmyb NinjaTrader Programming 12 February 5th, 2011 10:32 PM
Programming Indicators Using OnMarketData in NT7!!! RJay NinjaTrader Programming 3 December 16th, 2010 01:16 PM


All times are GMT -4. The time now is 06:44 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-12 in 0.15 seconds with 19 queries on phoenix via your IP 54.145.51.250