Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Lagged price
From
Beatrice Crozza <[email protected]>
To
statalist <[email protected]>
Subject
st: Lagged price
Date
Fri, 28 Jan 2011 23:08:07 +0100
Dear All,
I want to infer the trade direction with a tick test, comparing two
consecutive prices.
I have a problem with Stata in order to construct the lagged price.
When two consecutive prices are the same, I should go back one more
lag, however, often I need to compare my price with a price of three
or more previous periods.
Here there is an example of my dataset:
date time price
03jan2000 93157 148.25
03jan2000 93200 148.25
03jan2000 93201 148.27
03jan2000 93202 148.25
03jan2000 93203 148.25
03jan2000 93208 148.25
03jan2000 93211 148.25
03jan2000 93212 148.25
03jan2000 93215 148.15625
03jan2000 93225 148.25
if I compare price at 93212 with the previous one, it is the same and
also if I compare it with the price at 93208, so I should go further
until I reach the price of 93201 which is different.
If I want to do the difference for two consecutive prices I can write:
price[_n]-price[n-1]
a lag further:
price[_n]-price[_n-2]
and so on
However, I would like to know if there is a formula to do the
difference between to prices, until I find a price which is different
from the one in consideration.
Thank you very much or your help.
Bea
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/