Setting entry and exit position in Matlab and computing returns for backtesting purposes
조회 수: 2 (최근 30일)
이전 댓글 표시
I have to backtest a mean-reverting strategy that use the spread z and goes:
- long when the indicator z > -2;
- short-sell when the indicator z < 2;
The exit point is when the absolute value of z is equal to one.
How can I compute the returns using Matlab given those entry and exit position?
댓글 수: 0
답변 (1개)
Vitali Avagyan
2014년 8월 27일
편집: Vitali Avagyan
2014년 8월 27일
Hi Quantopic,
I guess you need these simple statements.
Bid=-10+20*rand();%depends on your data
Ask=-10+20*rand();%depends on your data
z=Bid-Ask;
if z>-2 && z~=abs(1)
outcome='long'
elseif z<2 && z~=abs(1)
outcome='short'
elseif z==abs(z)
outcome='exit'
end
댓글 수: 1
참고 항목
카테고리
Help Center 및 File Exchange에서 Transaction Cost Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!