Can somebody help me?...there is a code to do it?
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
how to find distance point-line
Collapse
X
-
Hello turbofib,
Thanks for opening the thread.
I do not have any example code I could share but this is certainly possible to write.
There are formulas that can be used to determine the distance from a point to a line. The shortest distance will form a perpendicular intercept to the line. You will want to find this line first, and then calculate the distance that line has between the point and where the two lines intersect.
There is a good publicly available resource for doing the math here: https://www.khanacademy.org/math/geo...int-and-a-line
I would suggest to look into converting the Price and Time/BarsAgo to pixel coordinates so then you have a common unit for the distance between the point and the line.
GetXByBarIndex() - https://ninjatrader.com/support/help...bybarindex.htm
GetYByValue() - https://ninjatrader.com/support/help...etybyvalue.htm
Other information for working with pixels can be found here: https://ninjatrader.com/support/help...oordinates.htm
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by SalmaTrader, 07-07-2026, 10:26 PM
|
0 responses
32 views
0 likes
|
Last Post
by SalmaTrader
07-07-2026, 10:26 PM
|
||
|
Started by CarlTrading, 07-05-2026, 01:16 PM
|
0 responses
20 views
0 likes
|
Last Post
by CarlTrading
07-05-2026, 01:16 PM
|
||
|
Started by CaptainJack, 06-17-2026, 10:32 AM
|
0 responses
12 views
0 likes
|
Last Post
by CaptainJack
06-17-2026, 10:32 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:15 AM
|
0 responses
18 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:15 AM
|
||
|
Started by kinfxhk, 06-17-2026, 04:06 AM
|
0 responses
20 views
0 likes
|
Last Post
by kinfxhk
06-17-2026, 04:06 AM
|

Comment