Data Manipulation in a series

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason

psingh
Posts: 1
Joined: Wed Oct 23, 2013 5:09 am

Data Manipulation in a series

Postby psingh » Wed Oct 23, 2013 5:24 am

Hi,
I am trying to create a series for signals for past 200 days such that if my signal on previous day was -1 ( exit a trade) ,my position becomes 0 today and if it was 1 on previous day (entry) , my position becomes +1 today. My Entry and exit signals comes from different series.

I am trying to code it like :

for !k=1 to 200
smpl @first+!end -200 @first+!end-(200-!k)
if @last(trade_pos(-1))=-1 then
@elem(trade_pos,!k) = 0
endif
if @last(trade_pos(-1))=1 then
@elem(trade_pos,!k) = 1
endif
next

But this doesn't seem to work. Is there a better way to do this ?

startz
Non-normality and collinearity are NOT problems!
Posts: 3797
Joined: Wed Sep 17, 2008 2:25 pm

Re: Data Manipulation in a series

Postby startz » Wed Oct 23, 2013 6:23 am

Hi,
I am trying to create a series for signals for past 200 days such that if my signal on previous day was -1 ( exit a trade) ,my position becomes 0 today and if it was 1 on previous day (entry) , my position becomes +1 today. My Entry and exit signals comes from different series.

I am trying to code it like :

for !k=1 to 200
smpl @first+!end -200 @first+!end-(200-!k)
if @last(trade_pos(-1))=-1 then
@elem(trade_pos,!k) = 0
endif
if @last(trade_pos(-1))=1 then
@elem(trade_pos,!k) = 1
endif
next

But this doesn't seem to work. Is there a better way to do this ?
Something like

Code: Select all

smpl 2 @last trade_pos=@recode(trade_pos(-1)=-1,0,trade_pos) trade_pos=@recode(trade_pos(-1)=1, 1,trade_pos)

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: Data Manipulation in a series

Postby EViews Glenn » Wed Oct 23, 2013 7:04 am

Startz's @recode does what the original code appears to be doing, but from the description of the problem (not the original code) the entry and exit series come from different sources which can make coming up with an equivalent @recode tricky. In this case, it's easy to do this with samples.

Code: Select all

series trade_pos smpl if exit(-1)=-1 trade_pos = 0 smpl if entry(-1)=1 trade_pos = 1
If entry and exit were the same, @recode would be fine, though I would recode into a new series instead of the existing series.


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 1 guest