Operations with series

Posted By: gtell

Operations with series - 07/28/16 13:36

Hi all,
Suppose you have the following series:

vars MA = series(SMA(Close, 21));


I want to calculate the difference with a shifted value:

MA[i] - MA[i+shift]

Where shift is a given int.
How can I do it?
Thanks
Posted By: gtell

Re: Operations with series - 07/29/16 11:28

I am not sure if you understand my question.
Simply, I want to calculate, for each bar, the difference with the bar which is n-times back. Where n-times is ithe value of the shift variable.
The result would be a series as well.
Could you help me or give an help?
Thanks.

PS.: May the solution be the following?

vars MAdiff = series(MA[0]-MA[shift]);


I need to test it in my laptop this night.
Posted By: jcl

Re: Operations with series - 07/29/16 13:31

Yes, series(MA[0]-MA[shift]) will get you the difference. Make sure that Lookback is >= shift.
© 2024 lite-C Forums