Thanks for the help.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
How can I measure the slope of a line?
Collapse
X
-
How can I measure the slope of a line?
Hello, how can I measure the slope of a line, in Ninja Trader?
Thanks for the help.Tags: None
-
Hello ELDAVIDOLOCO,
Thank you for your post.
Unfortunately, there is not a drawing tool to measure the slope. You can use Slope() in NinjaScript to measure the slope of a Plot/DataSeries: http://www.ninjatrader.com/support/h.../nt7/slope.htm
-
Even though, as Patrick says, there isn't a drawing tool to measure the slope, it can be calculated using some math that you may remember from school.Originally posted by ELDAVIDOLOCO View PostHello, how can I measure the slope of a line, in Ninja Trader?
Thanks for the help.
Let's say the start of the line is at Close[n] and the end at Close[0]. From geometry, we would say that X1 = n, Y1 = Close[n], X2 = 0 and Y2= Close[0].
The formula for the slope of such a a line is:
(X2 - X1)
-------------
(Y2 - Y1)
so in NinjaScript terms this comes out as:
(m being the conventional letter for 'slope'.)Code:double m = - n / (Close[0] - Close[n]);
Hope this helps.
Comment
-
Not to quibble, but actually slope is rise/run. You have that the wrong way round.Originally posted by arbuthnot View PostEven though, as Patrick says, there isn't a drawing tool to measure the slope, it can be calculated using some math that you may remember from school.
Let's say the start of the line is at Close[n] and the end at Close[0]. From geometry, we would say that X1 = n, Y1 = Close[n], X2 = 0 and Y2= Close[0].
The formula for the slope of such a a line is:
(X2 - X1)
-------------
(Y2 - Y1)
so in NinjaScript terms this comes out as:
(m being the conventional letter for 'slope'.)Code:double m = - n / (Close[0] - Close[n]);
Hope this helps.
Comment
-
Thanks, Koganam!
You are right - I am wrong!
My math degree has been rescinded and I'm sliding down the slippery - er - slope?
At my third attempt, this is the equation:
I was in a bad mood today until I saw this: a wonderful example of my absent-mindedness!Code:double m = (Close[n] - Close[0]) / n;
It's important to quibble otherwise wrong information can be left in the Forum, which helps no one.
Much obliged to you for pointing this out.
Cheers!
Ed
- Likes 1
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by CarlTrading, Yesterday, 11:48 AM
|
0 responses
8 views
0 likes
|
Last Post
by CarlTrading
Yesterday, 11:48 AM
|
||
|
Started by CaptainJack, 03-25-2026, 09:53 PM
|
0 responses
10 views
0 likes
|
Last Post
by CaptainJack
03-25-2026, 09:53 PM
|
||
|
Started by CaptainJack, 03-25-2026, 09:51 PM
|
0 responses
8 views
0 likes
|
Last Post
by CaptainJack
03-25-2026, 09:51 PM
|
||
|
Started by sjsj2732, 03-23-2026, 04:31 AM
|
0 responses
155 views
0 likes
|
Last Post
by sjsj2732
03-23-2026, 04:31 AM
|
||
|
Started by NullPointStrategies, 03-13-2026, 05:17 AM
|
0 responses
357 views
0 likes
|
Last Post
|

Comment