Dear Statalist member,
I have already asked this question but have not a response. Probably it was lost...
Let me ask you again hoping for some help as I am struggling to implement it several weeks.
I have panel data for 100 stocks. I have generated variable Trade_1. It takes value 1 for buy signal and -1 for sell.
My next step is to generate Trade_2. It is almost the same as Trade_1. The only difference is that I need to replace any signal with =. for the following 10 days.
In other words after a first buy/sell signal one should wait for the next 10 days and ignore any signals within this period.
I tried to do the following but it is wrong and does not work....
bysort _j (day_1): replace trade_2=1 if [f1.trade_1 +f2.trade_1 +f3.trade_1 +f4.trade_1 +f5.trade_1 +f6.trade_1 +f7.trade_1 +f8.trade_1 +f9.trade_1 +f10.trade_1 ]>0
bysort _j (day_1): replace trade_2=-1 if [f1.trade_1 +f2.trade_1 +f3.trade_1 +f4.trade_1 +f5.trade_1 +f6.trade_1 +f7.trade_1 +f8.trade_1 +f9.trade_1 +f10.trade_1 ]<0
May you please suggest how to delete each subsequent observation after the first signal?
Thank you.
Array
I have already asked this question but have not a response. Probably it was lost...
Let me ask you again hoping for some help as I am struggling to implement it several weeks.
I have panel data for 100 stocks. I have generated variable Trade_1. It takes value 1 for buy signal and -1 for sell.
My next step is to generate Trade_2. It is almost the same as Trade_1. The only difference is that I need to replace any signal with =. for the following 10 days.
In other words after a first buy/sell signal one should wait for the next 10 days and ignore any signals within this period.
I tried to do the following but it is wrong and does not work....
bysort _j (day_1): replace trade_2=1 if [f1.trade_1 +f2.trade_1 +f3.trade_1 +f4.trade_1 +f5.trade_1 +f6.trade_1 +f7.trade_1 +f8.trade_1 +f9.trade_1 +f10.trade_1 ]>0
bysort _j (day_1): replace trade_2=-1 if [f1.trade_1 +f2.trade_1 +f3.trade_1 +f4.trade_1 +f5.trade_1 +f6.trade_1 +f7.trade_1 +f8.trade_1 +f9.trade_1 +f10.trade_1 ]<0
May you please suggest how to delete each subsequent observation after the first signal?
Thank you.
Array