I've created a program that generates buy and sell signals of stocks. I've also created logic that tests the different signals and provides the return for each trade.
The next step is to simulate the strategy and its rules over a long period of time. All information is exported to text files and imported to a table in a SQL Server database. I've realized that I need to declare a number of variables such as StartCapital
, CurrentCapital
, NumberOfPositions
, PositionsLeft
. One of the columns is named BuyPrice
and indicates when to buy and to which price, when this occurs NumberOfPositions
should be subtracted by 1.
The column SellPrice
indicates when to sell and to which price, when this occurs NumberOfPositions
needs to be added by one. The maximum of NumberOfPositions
should be 5 and minimum 0. The desired result is to see how the CurrentCapital
unfolds.
I would very much appreciate any input and some kind of SQL code to start form.