Hi Everyone
The problem I have is that I have the table below:
Q Px
Buy 100 101
Buy 100 102
Buy 100 103
Sell 300 102
Buy 140 111
From this I want to find out what the average price is after the buys and sells become 0. I know how to say in words what to do in VBA but am having some problems actually doing it.
What I want to do is:
VBA Logic:
1. First step have I bought more or sold more? (Not a problem i can do this)
2. Then I want to loop down until the Buy and Sell equals 0 or near enough
3. Following this I want to start another loop AFTER the point that sells and buys become 0. This will then work out the the Average price after that
All i really need to know is how to start another loop after a certain point has been met. I am using the below code that I have written which tells me the Net position i but need to put something in there that tells me when i have reached 0 to start the second loop and start weighting the price against the quantity. (Not easy)
Any pointers would be greatly appreciated
Kind regards
Robin
Bookmarks