NexusFi: Find Your Edge


Home Menu

 





Problem with OnMarketData()


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one ratfink with 11 posts (7 thanks)
    2. looks_two ketron82 with 9 posts (2 thanks)
    3. looks_3 artemiso with 5 posts (8 thanks)
    4. looks_4 Big Mike with 4 posts (3 thanks)
      Best Posters
    1. looks_one artemiso with 1.6 thanks per post
    2. looks_two Big Mike with 0.8 thanks per post
    3. looks_3 NJAMC with 0.7 thanks per post
    4. looks_4 ratfink with 0.6 thanks per post
    1. trending_up 9,499 views
    2. thumb_up 24 thanks given
    3. group 4 followers
    1. forum 35 posts
    2. attach_file 0 attachments




 
Search this Thread

Problem with OnMarketData()

  #11 (permalink)
ketron82
Rome Italy
 
Posts: 27 since Feb 2012
Thanks Given: 7
Thanks Received: 4

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;
			}
		}

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Are there any eval firms that allow you to sink to your …
Traders Hideout
NexusFi Journal Challenge - April 2024
Feedback and Announcements
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
Better Renko Gaps
The Elite Circle
Exit Strategy
NinjaTrader
 
  #12 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,425


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
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #13 (permalink)
ketron82
Rome Italy
 
Posts: 27 since Feb 2012
Thanks Given: 7
Thanks Received: 4



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)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,425


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
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #15 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863

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

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
  #16 (permalink)
 
NJAMC's Avatar
 NJAMC 
Atkinson, NH USA
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,970 since Dec 2010
Thanks Given: 3,037
Thanks Received: 2,394


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
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #17 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,425


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
Visit my NexusFi Trade Journal Reply With Quote
  #18 (permalink)
 
ratfink's Avatar
 ratfink 
Birmingham UK
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader
Broker: TST/Rithmic
Trading: YM/Gold
Posts: 3,633 since Dec 2012
Thanks Given: 17,423
Thanks Received: 8,425


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
Visit my NexusFi Trade Journal Reply With Quote
  #19 (permalink)
 
rleplae's Avatar
 rleplae 
Gits (Hooglede) Belgium
Legendary Market Wizard
 
Experience: Master
Platform: NinjaTrader, Proprietary,
Broker: Ninjabrokerage/IQfeed + Synthetic datafeed
Trading: 6A, 6B, 6C, 6E, 6J, 6S, ES, NQ, YM, AEX, CL, NG, ZB, ZN, ZC, ZS, GC
Posts: 3,003 since Sep 2013
Thanks Given: 2,442
Thanks Received: 5,863


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

Follow me on Twitter Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #20 (permalink)
 
NJAMC's Avatar
 NJAMC 
Atkinson, NH USA
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,970 since Dec 2010
Thanks Given: 3,037
Thanks Received: 2,394



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
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:




Last Updated on March 28, 2015


© 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