Slope curve

Questions about MultiCharts and user contributed studies.
turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

Slope curve

Postby turbofib » 01 Oct 2014

Hi, i ask a question...
how can i calculate the slope of a curve with powerlanguage?

Code: Select all

value1=average(close,10);
i must calculate slope in value1 and plot it...

Thanks yoy

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Slope curve

Postby TJ » 01 Oct 2014

Hi, i ask a question...
how can i calculate the slope of a curve with powerlanguage?

Code: Select all

value1=average(close,10);
i must calculate slope in value1 and plot it...
Thanks yoy
If you can "define" slope... you can code it.

turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

Re: Slope curve

Postby turbofib » 01 Oct 2014

The slope expressed in Degrees

Ex:

value1=3;
Plot1(3);

degree is 0(zero);

value1=close;
Plot1(close);

degrees vary depending on the slope of the curve

When the curve is flat ... i will be near zero degrees


I need to know when the curve is flat

see pics below..
Attachments
Immagine_gradi.png
(6.26 KiB) Downloaded 1578 times

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Slope curve

Postby TJ » 01 Oct 2014

The slope expressed in Degrees
Ex:
value1=3;
Plot1(3);
degree is 0(zero);
value1=close;
Plot1(close);
degrees vary depending on the slope of the curve
When the curve is flat ... i will be near zero degrees
I need to know when the curve is flat
see pics below..
I asked you the definition of slope because different people have different interpretation of a slope.
In charting, knowing the slope in terms of "degree" is useless knowledge.

Because the degree changes, depending on the width of the chart interval.

Image
Attachments
slope.jpg
(17.32 KiB) Downloaded 1737 times

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Slope curve

Postby TJ » 01 Oct 2014

Maybe you are looking for...

when the slope is zero degrees? (ie. zero means there is no change in price)

or maybe the whether the slope is positive or negative? (the price is trending up, or down)


then,

what you are looking for is simply Slope = CLOSE minus CLOSE[1].

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Slope curve

Postby TJ » 01 Oct 2014

if you want to try out advanced math,

look up the following keywords and functions:

LinearRegAngle (Function)
LinearRegSlope (Function)
LinRegSlopeArray (Function)
CoefficientR (Function)
CoefficientRArray (Function)
CoefficientREasy (Function)
Correlation (Function)
CorrelationArray (Function)
TLAngle (Function)
Cosine (Reserved Word)
Sine (Reserved Word)
Tangent (Reserved Word)

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: Slope curve

Postby MAtricks » 01 Oct 2014

Try this:

Code: Select all

inputs:
MALength(20),
multiplier(5000) ;

variables:
MA(0),
MA1(0),
Angle(0);

MA = XAverage( C, MALength );
MA1 = XAverage( C[1], MALength );
Angle = (MA - MA1)/MA1*multiplier ;

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Slope curve

Postby TJ » 01 Oct 2014


turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

Re: Slope curve

Postby turbofib » 02 Oct 2014

See pics below..

i try to use linearregslope but i don't know if is correct....

the lines should be narrow and flat

Do you have any idea?

Thanks
Attachments
Immagine_angle2.png
(15.64 KiB) Downloaded 1608 times

shanemcdonald
Posts: 196
Joined: 08 Aug 2012
Has thanked: 41 times
Been thanked: 41 times

Re: Slope curve

Postby shanemcdonald » 02 Oct 2014

That looks good and it looks like you re on the right track.

Perhaps fine tune it so that it appears flat if within certain limits ?

turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

Re: Slope curve

Postby turbofib » 03 Oct 2014

is no good method....because you give use 2 point for slope function(linear regression)

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: Slope curve

Postby MAtricks » 03 Oct 2014

Use my code.. It's a simple way of approaching this, but it does exactly what you want.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Slope curve

Postby TJ » 03 Oct 2014

Use my code.. It's a simple way of approaching this, but it does exactly what you want.
MA1 = MA[1]

Why do you need to recalculate MA1?

turbofib
Posts: 213
Joined: 11 May 2013
Has thanked: 67 times
Been thanked: 1 time

Re: Slope curve

Postby turbofib » 04 Oct 2014

Use my code.. It's a simple way of approaching this, but it does exactly what you want.
MA1 = MA[1]

Why do you need to recalculate?
in your function you fixed the value of the volatility at 20..

if it changes the volatility must change the value

User avatar
MAtricks
Posts: 789
Joined: 09 Apr 2012
Has thanked: 286 times
Been thanked: 288 times

Re: Slope curve

Postby MAtricks » 05 Oct 2014

Use my code.. It's a simple way of approaching this, but it does exactly what you want.
MA1 = MA[1]

Why do you need to recalculate MA1?
Just keeping things clear for those who are less experienced...


Return to “MultiCharts”