Is there a NinjaScript method or other easy solution for converting the .NET Point type to X/Y (Bars/Price) coordinates and vice versa?
Announcement
Collapse
Looking for a User App or Add-On built by the NinjaTrader community?
Visit NinjaTrader EcoSystem and our free User App Share!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less
Partner 728x90
Collapse
NinjaTrader
Point type to Bars/Price converter?
Collapse
X
-
-
Hello,
Thank you for the question.
There are easy methods for this hidden in the ChartControl.
For X coordinates by bar number, you can use:
Code:ChartControl.GetXByBarIdx(BarsArray[0], 100)
Code:ChartControl.GetXByTime(Time[0]);
Code:ChartControl.GetYByValue(this, 2000);
Code:if(ChartControl != null) { //do stuff }
JesseNinjaTrader Customer Service
-
How do we convert back from the .NET x,y coordinates to NinjaTrader barnumber/price?
So we might have something like
double x = ChartControl.GetXByBarIdx(BarsArray[0], barnumber);
double y = ChartControl.GetYByValue(this, pricevalue);
//do some calculations using x,y and get updated values x1,y1
//we then want
int barnumber = GetBarNumber(x1);
double priceval = GetPrice(y1);
This is just dummy code but how would GetBarNumber(), GetPrice() be implemented?
Comment
-
Hello,
Thank you for the question.
For NT7 I would have no suggestion here as there are no exposed methods for this that I could relay. Going forward in NT8 the ChartControl and other chart-related coordinate methods have all been exposed so you can translate back and forth between coordinate and price/time.
If any other NT7 users have custom solutions for this question an answer would be welcome for any undocumented/unsupported solutions.
I look forward to being of further assistance.JesseNinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Rapine Heihei, Today, 08:19 PM
|
1 response
6 views
0 likes
|
Last Post Today, 08:30 PM | ||
Started by Rapine Heihei, Today, 08:25 PM
|
0 responses
5 views
0 likes
|
Last Post Today, 08:25 PM | ||
Started by f.saeidi, Today, 08:01 PM
|
1 response
4 views
0 likes
|
Last Post Today, 08:17 PM | ||
Change colour of Stop market and limit orders to red and green via indicator script
by Rapine Heihei
Started by Rapine Heihei, Today, 07:51 PM
|
0 responses
6 views
0 likes
|
Last Post Today, 07:51 PM | ||
Started by frslvr, 04-11-2024, 07:26 AM
|
5 responses
98 views
1 like
|
Last Post
by caryc123
Today, 07:47 PM
|
Comment