Slope function. how?

Posted By: NewtraderX

Slope function. how? - 04/09/21 02:36

Hello all,

This sample code is from the manual, it works fine just as it is.

var HighsDn[10] = { 1,1,1,2,1,1,1,3,1,1 }; // mind the reverse order
var LowsUp[10] = { 1,1,1,0.7,1,1,1,0.5,1,1 };

function main()
{
printf("\nSlope dn %.3f",slope(PEAK,HighsDn,10));
printf("\nSlope up %.3f",slope(VALLEY,LowsUp,10));
plot("DPO", HighsDn[10], LINE, BLUE);
plot("DPOd", LowsUp[10], LINE, RED);
}


However, when I use slope function on price series instead of HighsDn or LowsUp I don't get any values.

Do you have a sample for using slope function with price series?

Such as below:


function run()
{
BarPeriod=5;
LookBack = 100;
StartDate = 20210103;
EndDate = 20210104;

var* Price = series(price());

vars MM2 = series(SMA(Price,20));

printf("\n+");

printf("\nPEAK %.3f",slope(PEAK,MM2,5));
printf("\nVALLEY %.3f",slope(VALLEY,MM2,5));
}

zorro image that is result of running my script is below:
https://prnt.sc/117scg1

Thank you.
Posted By: NewtraderX

Re: Slope function. how? - 04/09/21 13:40

Can anyone find the problem with my script?
Posted By: NewtraderX

Re: Slope function. how? - 04/09/21 18:31

I have no clue on how to get this to work.
Can you guys point me to some a direction?
Posted By: jcl

Re: Slope function. how? - 04/13/21 06:19

Look at your printf call. The slope is the price movement per bar. Are 3 decimals enough?
Posted By: NewtraderX

Re: Slope function. how? - 04/15/21 00:58

Originally Posted by jcl
Look at your printf call. The slope is the price movement per bar. Are 3 decimals enough?

Thank you sir.
© 2024 lite-C Forums