[pnl,pnlvector, sh]= backtestlongAmount(data,signal,buyprice,delay,amount$$);
This is a very basic function for backtesting a strategy in Matlab.
All you need is a vector with 1s for Buy, -1's for Sell and 0's for Hold.
To use it we need
1. A vector of prices,i.e. SPY close prices
2. Signal: A vector of 1 for BUY, -1 for SELL and 0 for HOLD
3. Buyprice: A vector of Close prices if we buy at close or Open prices if we buy at Open
4. Delay: 0 if we buy "Today" - 1 if we buy tomorrow. So to Buy Tomorrow on Open:
4. Amount :i.e., 100,000
Please report any bugs or inaccuracies you find. Improvements are welcome.
Labels: backtest, Buy, econometrics, financial, function, Market, Matlab, PnL, Sell, simple, Stock