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
Function to Get the slope of anything [SOLVED]
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times
Re: Function to Get the slope of anything
Can you define your meaning of "Slope"?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
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
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: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times
Re: Function to Get the slope of anything
if that is your definition, then consider this for a moving average: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
Code: Select all
slope = MA - MA[1]
Code: Select all
slope = (MA[start.point] - MA[end.point]) / (end.point - start.point)
- TJ
- Posts: 7740
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2221 times
- Stan Bokov
- Posts: 963
- Joined: 18 Dec 2009
- Has thanked: 367 times
- Been thanked: 302 times