Automatically updating recession shading

For posting your own programs to share with others

Moderators: EViews Gareth, EViews Moderator

jjacobs
Posts: 1
Joined: Wed Jun 05, 2013 11:27 am

Automatically updating recession shading

Postby jjacobs » Wed Jun 05, 2013 11:34 am

If you have access to an automatically updating series which is 1 for recession quarters and 0 for non-recession quarters, this subroutine should be callable to add recession shading bars to any eviews graph. Just replace recessq2 with your recession series.:

Code: Select all

subroutine recession_shade(graph inputted_name)

series date = @date
series recessq2a=recessq2

smpl  if recessq2=1 and recessq2(-1)=1 and recessq2(1)=1
recessq2a=0

smpl if recessq2a=1 and date <> na
vector recstend=date

smpl if recessq2=na
recessq2=0

smpl @first @first
if recessq2=0 then
     for !i=1 to recstend.@rows-1 step 2
           %date0 = @datestr(recstend(!i),"yyyy[Q]q")
           %date1 = @datestr(recstend(!i+1), "yyyy[Q]q")
           inputted_name.draw(shade,bottom) {%date0} {%date1}
     next
else
     %date2 = @datestr(recstend(1),"yyyy[Q]q")
     inputted_name.draw(shade,bottom) @first {%date2}
     for !i=2 to recstend.@rows-1 step 2
           %date0 = @datestr(recstend(!i),"yyyy[Q]q")
           %date1 = @datestr(recstend(!i+1), "yyyy[Q]q")
           inputted_name.draw(shade,bottom) {%date0} {%date1}
     next
endif       

endsub

Return to “Program Repository”

Who is online

Users browsing this forum: No registered users and 1 guest