Go Back   NinjaTrader Support Forum > NinjaTrader 8 > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Thread Tools Display Modes
Old 09-19-2017, 04:42 PM   #1
Senior Member
Join Date: Nov 2007
Location: Arlington Heights, IL
Posts: 263
Thanks: 4
Thanked 27 times in 25 posts
Default Posible x,y coordinate bug(?) when Scale Justification changes

I found an 'anomaly' when conparing the value returned by:
- mouseEventArgs.GetPosition(ChartControl) versus
- ChartControl.MouseDownPoint.

I found that when all indicators have their Scale justification set to Right, the values are the same. However, if an indicator is switched so it's Scale justification is set to Left, then the X value returned is different by quite a bit.

To demonstrate this issue, I have attached two indicators. One prints the x/y coordinates of mouse clicks on the chart. The other plots the Close value as a line.
Open the output window.

To see things work correctly, load both indicators on a chart and click somewhere in the chart. Observe the output window. There should be two lines printed showing the x/y coordinates, one set obtained from GetPosition, the next set obtained from MouseDownPoint.

To see the bug, Change the Scale justification of GTestIndicatorShowingOnLeftMargin to be Left.
Now when you click on the chart, the X values of the two sets of coordinates are different.

I assume ChartPanel.MouseDownPoint is the ninja supported way of determining mouse click coordinates. If GetPosition is not a supported technique, then it should be clearly documented with warnings.

New Feature request:
If ChartPanel is the only correct way to determine the mouse coordinates, then there needs to be a new public property/method added to track the coordinates of a MouseMove event (since there is no down click in this event, the MouseDownPoint provided by Ninja does not help).

Attached Files
File Type: cs GTestIndicatorShowingOnLeftMargin.cs (4.3 KB, 4 views)
File Type: cs GTestMouseClickOnChart.cs (6.1 KB, 4 views)
GaryAlbers is offline  
Reply With Quote
The following user says thank you to GaryAlbers for this post:
Old 09-20-2017, 09:06 AM   #2
NinjaTrader Customer Service
NinjaTrader_Jim's Avatar
Join Date: Nov 2016
Location: Denver, CO
Posts: 1,727
Thanks: 93
Thanked 468 times in 443 posts

Hello GaryAlbers,

Thank you for the concise and straight forward report!

We're taking a closer look and I will update this post with our findings.
NinjaTrader_Jim is offline  
Reply With Quote
Old 09-25-2017, 11:40 AM   #3
NinjaTrader Customer Service
NinjaTrader_Jim's Avatar
Join Date: Nov 2016
Location: Denver, CO
Posts: 1,727
Thanks: 93
Thanked 468 times in 443 posts

Hello GaryAlbers,

So after a closer look we see that the code is comparing the coordinates from ChartPanel to the coordinates from ChartControl. ChartPanel coordinates will adjust with the margin, while the ChartControl will contain the margin and the coordinates will be unaffected.

My lead has created a graphic that can be used to visualize. I've attached it to this post.

I've also requested that this is detailed in the MouseDownPoint page of the help guide.

Please let me know if I can be of further assistance.
Attached Images
File Type: jpg CCCPLeft.jpg (114.7 KB, 4 views)
NinjaTrader_Jim is offline  
Reply With Quote

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
Scale Justification Steve R Indicator Development 3 11-08-2013 06:24 AM
Left Scale Justification Jaba1n Platform Technical Support 10 01-10-2012 01:08 PM
indicator scale justification madLyfe Platform Technical Support 3 05-24-2011 04:29 PM
Scale justification from NinjaScript. koganam Indicator Development 1 08-24-2010 03:01 AM

All times are GMT -6. The time now is 10:02 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.