Create Code frrom scratch

3 views (last 30 days)
Pap
Pap on 14 Sep 2011
Hello all,
I am new with MATLAB and I try to implement the below code:
My inputs come from an ASCII file like:
Stock Date T(t) P(t) V(t) Market
ETE 04/01/2010 10170000 18.54 430 Big Cap
ETE 04/01/2010 10190000 18.90 890 Big Cap
The steps are:
  • Inputs:
T(i) = Time vector
P(i) = Price vector
V(i) = Volume vector
K = exogenously defined by the user ( to try different outcomes)
n = exogenously defined by the user ( to try different outcomes)
The steps are as follows:
  • 1. Sort by Time ascending T(i+1)> T(i)
  • 2. Expand the number of P(i) as many times as V(i), with i=1..._I_ So sum of new rows with Pi, will equal V(i).
  • 3. Re-index P(i) for i=1..._I_ as time ascending
  • 4. Initiate counter, t=0
  • 5. Add one unit to t.
  • 6. If I <tK,go to step 10 (insufficient data)
  • 7. For every i belonging [ (t-1)K +1, tK] classify each transaction (row) as 'BUY' or 'SELL' as
a. transaction is 'BUY' if Pi>Pt-1 or Pi=Pt-i and transaction (t-1) (previou row) was 'BUY'
b. otherwise the transaction is 'SELL'.
  • 8. Assign to variable KB(t) the number of variables classified as 'BUY' in step 7. Assign to variable KS the number of variables classified as 'SELL' in step 7, so K(t)=KB(t)+KS(t)
  • 9. Loop to step 6.
10. Set L=t-1 ( last bucket, not for use)
11. If L>=n Calculate
X= (SUM(t)abs(KS(t)-KB(t)) / n*K
% for t=L-n+1 until n=L
Many thanks for any helpfull comment in advance
Panos
  2 Comments
Walter Roberson
Walter Roberson on 14 Sep 2011
Please indicate more clearly what your question is, what you would like to know?
Pap
Pap on 14 Sep 2011
I cannot write a MATLAB code for steps 1-11
Any help?
Panos

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 14 Sep 2011

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!