Select Page

# MA Slope

This topic contains 2 replies, has 2 voices, and was last updated by  Nigel 3 months, 3 weeks ago.

Viewing 3 posts - 1 through 3 (of 3 total)
• Author
Posts
• #46607

Nigel
• Topics: 3
• Replies: 3
• Posts: 6

Hi,

Is it possible to display (via a script, in the watchlist) the degree of a slope.

In the pic below, the slope of the 5 SMA is 132.17 degrees.

How can I calculate this number (degree) so that it displays in the watchlist.

At present I have MA(BARS=5, STYLE=Simple) IsUp, but that only gives me a true / false value, not a number.

Any help would be appreciated.

E.g.

#46623

Mathew
• Topics: 14
• Replies: 773
• Posts: 787

Hi Nigel,

A simple way would be to take the difference in price over a set number of bars and then divide that by the bars.

eg

v1 = MA(Bars=10);
(v1 -v1[10]) / 10

But essentially that is the same as the Momentum tool, so you can use that instead.

v1 = MA(BARS=10);
MOMENTUM(v1)

This is a ratio and not an angle, but the concern I have is that when we put TA values into a watchlist, we do that because we want to compare and rank them. The issue is that the “slope” is different for each security that we are looking at, so a 50c/day slope on a \$1 security is very different when it happens on a \$100 security.

The only way that you could do that is to “normalise” price first. I like using ATRs for that as I can then normalise using the volatility of the security.

eg

v1 = MA(BARS=10);
v2 = ATR();
MOMENTUM(v1)/v2

With this, you will have a slope for the MA that is able to be compared between different securities.

Hope that helps

Mathew

#46639

Nigel
• Topics: 3
• Replies: 3
• Posts: 6

Matthew,

Thanks for the quick response & the coding ideas.

Nigel.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

### Pin It on Pinterest

Share This

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close