Create Code frrom scratch
조회 수: 2 (최근 30일)
이전 댓글 표시
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
Walter Roberson
2011년 9월 14일
Please indicate more clearly what your question is, what you would like to know?
채택된 답변
Walter Roberson
2011년 9월 14일
I recommend you review this previous Question: http://www.mathworks.com/matlabcentral/answers/8026-best-way-s-to-master-matlab
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!