I want to compare the data of two stocks, stock A and stock B. When I buy stock A, I sell stock B. (The type of trading is called pairtrading.) I want to have a formula / program (visual basic) that can backtest this strategy and that can optimize this strategy aswell. For example: My account is $25.000 and to set up 1 time this strategy (buy A, sell A) it will cost me $7500 in margin. That leaves $17.500 in assets on my account... when the difference between A and B gets bigger I want to increase my positions and buy more of share A and sell share B.
So I want to know when to trade at what moment...so when do I set up the second pair. With the data, that will be provided by me, you have to do the analyses. I want to see:
1) profit in $ and % per year.
2) max drawdown
I want to be able to use the program for other pairs. Because I do most trades with futures i work with margin. The stockprice is not important, I want to be able to fill in the margin per trade (+1 A & - 1 B= set) 1 set is margin $7500 example.
Hope that I could make clear what I am looking for.