Go Back   NinjaTrader Support Forum > NinjaTrader 8 > Add-On Development

Add-On Development General NinjaScript development questions.

NinjaTrader
Reply
 
Thread Tools Display Modes
Old 04-19-2018, 04:58 PM   #1
Zeos6
Senior Member
 
Join Date: Jan 2011
Posts: 633
Thanks: 22
Thanked 43 times in 37 posts
Default AddBar Question

Hi,

When creating a custom bar type, in the OnDataPoint() method when AddBar() is used, it seems that the arguments in the call to the AddBar method are rounded to the nearest instrument tick size when the bar is added. Is this correct? If yes, is there a way to simply add just the raw data rather than have the raw data rounded off to the nearest instrument tick size?
Zeos6 is offline  
Reply With Quote
Old 04-20-2018, 10:58 AM   #2
NinjaTrader_Jesse
NinjaTrader Customer Service
 
NinjaTrader_Jesse's Avatar
 
Join Date: Mar 2014
Location: Denver, CO
Posts: 4,705
Thanks: 29
Thanked 1,199 times in 1,120 posts
Default

Hello Zeos6,

Thank you for the post.

I dont believe there would be an easy way around this except to change the instruments master tick size. The rounding you are seeing would be expected, all BarsTypes are rounded to the Instrument tick size that's defined. As far as I am aware, that would be the only correct way or to change the tick size.

I look forward to being of further assistance.
NinjaTrader_Jesse is offline  
Reply With Quote
Old 04-20-2018, 12:40 PM   #3
Zeos6
Senior Member
 
Join Date: Jan 2011
Posts: 633
Thanks: 22
Thanked 43 times in 37 posts
Default

Hi Jesse,

Thank you for your reply. So what I am trying to do is essentially paint my own BarSeries. I want to take in the streaming data, process the data and paint bars based on the processed data. I am thinking that AddBar() is a wrapper that filters the argument data and passes the results to a paint factory of some sort.

I did not think of the possibility of changing the master instrument tick size. Two questions:

1. How would I do this?
2. Can this change be done so that it only affects a single chart and leaves the other charts of the same instrument unaffected?
Zeos6 is offline  
Reply With Quote
Old 04-20-2018, 12:58 PM   #4
NinjaTrader_Jesse
NinjaTrader Customer Service
 
NinjaTrader_Jesse's Avatar
 
Join Date: Mar 2014
Location: Denver, CO
Posts: 4,705
Thanks: 29
Thanked 1,199 times in 1,120 posts
Default

Hello Zeos6,

Thank you for the post.

If you need something other than the tick size, this would be a good use case for an indicator that is not bound to a specific TickSize.

The BarsType will use the TickSize for the instrument being used. I dont believe there is any way to use the BarsType in the way you want without adjusting the overall tick size.

Please let me know if I may be of further assistance.
NinjaTrader_Jesse is offline  
Reply With Quote
Old 04-20-2018, 02:13 PM   #5
Zeos6
Senior Member
 
Join Date: Jan 2011
Posts: 633
Thanks: 22
Thanked 43 times in 37 posts
Default

Hi Jesse,

I am not sure what you are saying here. Is there any way to paint the bar series without having tick size restrictions? Are saying I need to build an indicator to paint the bars?
Zeos6 is offline  
Reply With Quote
Old 04-20-2018, 02:39 PM   #6
NinjaTrader_Jesse
NinjaTrader Customer Service
 
NinjaTrader_Jesse's Avatar
 
Join Date: Mar 2014
Location: Denver, CO
Posts: 4,705
Thanks: 29
Thanked 1,199 times in 1,120 posts
Default

Hello Zeos6,

No there is not, the chart renders based on the instruments/series being used and TickSize is a big part of how that all works.

What I had meant is that if the TickSize is going to limit your idea, you would need to use a different type rather than a BarsType. An indicator is not locked to the TickSize so perhaps that could be used for your ideas. This would be something you could investigate as it is not clear what your overall goal is aside from trying to use a BarsType.

Alternatively, you would need to change the instruments tick size in the instrument manager so the bars can be built with a different granularity for the values displayed. If you have data with a granularity of 0.00001 but have a tick size of 0.01, you will lose the difference in granularity when the bars are built due to the settings for the Instrument being used.

Please let me know if I may be of further assistance.
NinjaTrader_Jesse is offline  
Reply With Quote
The following user says thank you to NinjaTrader_Jesse for this post:
Old 04-20-2018, 03:33 PM   #7
Zeos6
Senior Member
 
Join Date: Jan 2011
Posts: 633
Thanks: 22
Thanked 43 times in 37 posts
Default

Hi Jesse,

Basically I am trying to paint my own custom bars, and to paint them tick size is irrelevant. For example, the ES futures contract has a tick size of 0.25. That means that all bar ranges for ES will be integer multiples of 0.25. But lets say I want to build an ES bar that has a range of say 1.1 points. This is a range of 4.4 ticks. How would I do that?
Zeos6 is offline  
Reply With Quote
Old 04-20-2018, 03:45 PM   #8
NinjaTrader_Jesse
NinjaTrader Customer Service
 
NinjaTrader_Jesse's Avatar
 
Join Date: Mar 2014
Location: Denver, CO
Posts: 4,705
Thanks: 29
Thanked 1,199 times in 1,120 posts
Default

Hello Zeos6,

To make bars that end in .1, you would need a ticksize that includes 0.1. The bars can break however your logic determines but the prices that are shown are segmented based on the TickSize. You can experiment with this by changing an instruments tick size, and then import your data and view a chart. For example if I changed the ES from 0.25 to 0.1, the prices on the chart would look like the following image:
https://lh3.googleusercontent.com/-A...0_15-44-42.png



Please let me know if I may be of further assistance.
NinjaTrader_Jesse is offline  
Reply With Quote
Old 04-20-2018, 04:02 PM   #9
Zeos6
Senior Member
 
Join Date: Jan 2011
Posts: 633
Thanks: 22
Thanked 43 times in 37 posts
Default

Hi Jesse,

Thank you for the reply. Ok. I do not mind the axis looking like that. I can adjust the axis properties to get the look I want. And then I can use the logic in AddBars() to create my own range, right? I will give that a try and see how that works. By the way, if you have any code snippet that might achieve what I am after I'd really appreciate it. Thank you for your suggestions and your help..

As an aside, it would be really nice to give us the ability to paint our own bars without the tick size restriction. A number of platforms already do that and I don't think it should be that much of an issue if AddBar() is a wrapper of some sort. Just a suggestion.

EDIT:
As an aside, is there any way I can create a duplicate of an instrument and give it a different name? So using the case above, I'd like to leave ES at the 0.25 tick size but create another version of ES, say I call It ES*, and give the duplicate the 0.1 tick size.
Last edited by Zeos6; 04-20-2018 at 04:21 PM.
Zeos6 is offline  
Reply With Quote
Old 04-23-2018, 08:37 AM   #10
NinjaTrader_Jesse
NinjaTrader Customer Service
 
NinjaTrader_Jesse's Avatar
 
Join Date: Mar 2014
Location: Denver, CO
Posts: 4,705
Thanks: 29
Thanked 1,199 times in 1,120 posts
Default

Hello Zeos6,

Thank you for the post.

I would suggest looking at how the existing BarsTypes and how they are created if you are interested in learning how to make one. The BarsType is simply for breaking the data into chunks which later can be supplied to the chart or indicators. If you are interested in Ranges, you may look at the Range bar type or Renko for some ideas.

Regarding the instrument, you can define custom instruments if you would like using the Instrument manager. You could certainly create a second ES instrument with different settings. The existing instrument can be referenced for the values needed, and then you could modify them as needed.

One note is that changing the tick size can prevent trades from being accepted by some brokers, there can also be issues if you try to trade both a custom instrument and the standard instrument using the same symbol map simultaneously. It would be advisable to not use the custom instruments for trading specifically.


I look forward to being of further assistance.
NinjaTrader_Jesse is offline  
Reply With Quote
Old 04-23-2018, 08:49 AM   #11
Zeos6
Senior Member
 
Join Date: Jan 2011
Posts: 633
Thanks: 22
Thanked 43 times in 37 posts
Default

Thanks Jesse.
Can you please let me know more information about creating a duplicate instrument? How would I go about doing it? Will it get updated same way as the base instrument?
Zeos6 is offline  
Reply With Quote
Old 04-23-2018, 09:00 AM   #12
NinjaTrader_Jesse
NinjaTrader Customer Service
 
NinjaTrader_Jesse's Avatar
 
Join Date: Mar 2014
Location: Denver, CO
Posts: 4,705
Thanks: 29
Thanked 1,199 times in 1,120 posts
Default

Hello Zeos6,

I would suggest reviewing the help guide section we have on editing Instruments with the instrument manager:
https://ninjatrader.com/support/help...nstruments.htm
https://ninjatrader.com/support/help...ment%2Bmanager

When you open a chart to an instrument or use any tool that selects an instrument you are creating a subscription to that instrument. Assuming you have used valid settings, you should then see the instrument's data and get updates for it.

Please let me know if I may be of further assistance.
NinjaTrader_Jesse is offline  
Reply With Quote
Old 04-23-2018, 09:29 AM   #13
Zeos6
Senior Member
 
Join Date: Jan 2011
Posts: 633
Thanks: 22
Thanked 43 times in 37 posts
Default

Thanks Jesse but this is not very helpful to me. I l looked at the material and it seems that each instrument is linked to a data provider. I am still unsure how to add an instrument based off a real instrument.
Zeos6 is offline  
Reply With Quote
Old 04-23-2018, 10:02 AM   #14
NinjaTrader_Jesse
NinjaTrader Customer Service
 
NinjaTrader_Jesse's Avatar
 
Join Date: Mar 2014
Location: Denver, CO
Posts: 4,705
Thanks: 29
Thanked 1,199 times in 1,120 posts
Default

Hello Zeos6,

Yes, that is correct, each data provider has their own symbol mapping schema which you can see many examples in the existing predefined instruments.

If you will be duplicating an instrument, you would need to just copy the settings that you can see in the original instrument into the new instrument including the symbol mapping.

Please let me know if I may be of further assistance.
NinjaTrader_Jesse is offline  
Reply With Quote
Old 04-23-2018, 10:12 AM   #15
Zeos6
Senior Member
 
Join Date: Jan 2011
Posts: 633
Thanks: 22
Thanked 43 times in 37 posts
Default

Hi Jesse,

So do I just give it my own name in the Master Instrument part of the General tab and replicate the mappings as, for example, in the ES?
Zeos6 is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
AddBar example code anyone? ours_solaire Version 8 Beta 1 08-05-2016 02:18 PM
Question for the Community not exactly a support question Crassius Indicator Development 4 03-15-2013 06:44 AM


All times are GMT -6. The time now is 11:09 PM.

Futures, foreign currency and options trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. View Full Risk Disclosure.

CFTC Rules 4.41 - Hypothetical or Simulated performance results have certain limitations, unlike an actual performance record, simulated results do not represent actual trading. Also, since the trades have not been executed, the results may have under-or-over compensated for the impact, if any, of certain market factors, such as lack of liquidity. Simulated trading programs in general are also subject to the fact that they are designed with the benefit of hindsight. No representation is being made that any account will or is likely to achieve profit or losses similar to those shown.

This website is hosted and operated by NinjaTrader, LLC (“NT”), a software development company which owns and supports all proprietary technology relating to and including the NinjaTrader trading platform. NT is an affiliated company to NinjaTrader Brokerage (“NTB”), which is a NFA registered introducing broker (NFA #0339976) providing brokerage services to traders of futures and foreign exchange products. This website is intended for educational and informational purposes only and should not be viewed as a solicitation or recommendation of any product, service or trading strategy. No offer or solicitation to buy or sell securities, securities derivative or futures products of any kind, or any type of trading or investment advice, recommendation or strategy, is made, given, or in any manner endorsed by any NT affiliate and the information made available on this Web site is not an offer or solicitation of any kind. Specific questions related to a brokerage account should be sent to your broker directly. The content and opinions expressed on this website are those of the authors and do not necessarily reflect the official policy or position of NT or any of its affiliates. 

Vendors along with their websites, products and services, collectively referred to as (“Vendor Content”), are independent persons or companies that are in no manner affiliated with NT or any if its affiliates. NT or any of its affiliates are not responsible for, do not approve, recommend or endorse any Vendor Content referenced on this website and it’s your sole responsibility to evaluate Vendor Content. Please be aware that any performance information provided by a vendor should be considered hypothetical and must contain the disclosures required by NFA Rule 2-29(c). If you are interested in learning more about, or investigating the quality of, any such Vendor Content you must contact the vendor, provider or seller of such Vendor Content. No person employed by, or associated with, NT or any of its affiliates is authorized to provide any information about any such Vendor Content.