| View previous topic :: View next topic |
| Author |
Message |
Rigi583
Joined: 13 Jan 2010 Posts: 2 Location: Switzerland
|
Posted: Wed Jan 13, 2010 1:09 pm Post subject: Create new data series |
|
|
Hi
I am intending to make a new data series but I have no idea where to start. The basic of that series should be the following:
If close(t)>close(t-1) then 1
If close(t)=close(t-1) then 0 else -1
Does anyone have an idea?
Thanks a lot for your help! |
|
| Back to top |
|
 |
koolaidluke
Joined: 25 May 2009 Posts: 54
|
Posted: Thu Feb 04, 2010 9:59 pm Post subject: |
|
|
Hi Rigi583. I'm sorry you had to wait so long for a reply. I think the following inelegant code snippet will do what you want.
| Code: |
Series newseries = 0*closeSeries();
for (Index j=1;j<newseries.size();j++) {
if (close(j)>close(j-1))
newseries[j] = 1;
else if (close(j)<close(j-1))
newseries[j] = -1;
} |
This code is 100% untested, so, you know, beware. Good luck. |
|
| Back to top |
|
 |
Rigi583
Joined: 13 Jan 2010 Posts: 2 Location: Switzerland
|
Posted: Fri Feb 05, 2010 10:07 am Post subject: |
|
|
Hi koolaidluke
Thanks a lot for your reply. Will test it and see how it works! |
|
| Back to top |
|
 |
|