Create Code frrom scratch
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Walter Roberson
le 14 Sep 2011
Please indicate more clearly what your question is, what you would like to know?
Réponse acceptée
Walter Roberson
le 14 Sep 2011
I recommend you review this previous Question: http://www.mathworks.com/matlabcentral/answers/8026-best-way-s-to-master-matlab
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!