Setting entry and exit position in Matlab and computing returns for backtesting purposes

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?

回答 (1 件)

Vitali Avagyan
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 件のコメント

Josh Perry
Josh Perry 2015 年 7 月 18 日
how is a strategy like this backtested in matlab.... HELP PLEASE!

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeTransaction Cost Analysis についてさらに検索

質問済み:

2014 年 8 月 27 日

コメント済み:

2015 年 7 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by