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 ?
Data Manipulation in a series
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3797
- Joined: Wed Sep 17, 2008 2:25 pm
Re: Data Manipulation in a series
Something likeHi,
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 ?
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
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.
If entry and exit were the same, @recode would be fine, though I would recode into a new series instead of the existing series.
Code: Select all
series trade_pos
smpl if exit(-1)=-1
trade_pos = 0
smpl if entry(-1)=1
trade_pos = 1
Who is online
Users browsing this forum: No registered users and 1 guest
