# Function to Get the slope of anything

Questions about MultiCharts and user contributed studies.
Kingjelly
Posts: 26
Joined: 23 Jan 2008

### Function to Get the slope of anything

Hi,

Has anyone by chance written a function that can be called to get the slope of a moving average, or indicator or anything you want pass to it?

Thanks,

Preston

TJ
Posts: 7459
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 999 times
Been thanked: 2138 times

### Re: Function to Get the slope of anything

Hi,

Has anyone by chance written a function that can be called to get the slope of a moving average, or indicator or anything you want pass to it?

Thanks,

Preston
Can you define your meaning of "Slope"?

Kingjelly
Posts: 26
Joined: 23 Jan 2008

### Re: Function to Get the slope of anything

TJ,

rise over run

Rules for Calculating the Slope of a Line

# Find two points on the line.

# Count the rise (How many units do you count up or down to get from one point to the next?) Record this number as your numerator.

# Count the run (How many units do you count left or right to get to the point?) Record this number as your denominator.

# Simplify your fraction if possible.

IMPORTANT NOTE:

# If you count up or right your number is positive.

# If you count down or left your number is negativ

TJ
Posts: 7459
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 999 times
Been thanked: 2138 times

### Re: Function to Get the slope of anything

TJ,

rise over run

Rules for Calculating the Slope of a Line

# Find two points on the line.

# Count the rise (How many units do you count up or down to get from one point to the next?) Record this number as your numerator.

# Count the run (How many units do you count left or right to get to the point?) Record this number as your denominator.

# Simplify your fraction if possible.

IMPORTANT NOTE:

# If you count up or right your number is positive.

# If you count down or left your number is negativ
if that is your definition, then consider this for a moving average:

Code: Select all

`slope = MA - MA[1]`
or

Code: Select all

`slope = (MA[start.point] - MA[end.point]) / (end.point - start.point)`

TJ
Posts: 7459
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 999 times
Been thanked: 2138 times

### Re: Function to Get the slope of anything

you can get more slope information here:

Stan Bokov
Posts: 963
Joined: 18 Dec 2009
Has thanked: 367 times
Been thanked: 302 times

Thanks, TJ.