Financial Stats Formula to work out how much you could loose if you were X% of...

Hello,

I've been trying to come up with a formula for the following.

I have 100,000 of X stock which i want to sell

I only want to be 20% of the market each day and no more.

How many days will it take to liquidate and how much on average will i loose or make.

I have a large amount of historical data so volumes for every day and the Change in price for the days.

I have produced a spreadsheet that i think basically does the job however its figures are stupid it suggests a loss of 69% for example.

Whats going wrong and how can i correct it?

basically what im doing is the following: WAvgCost = WAvgCost + volume.Cells(numRows) * chngeOnDay.Cells(numRows) / targetVolume and for the last volume traded on a day i take the % of that needed to make the target volume: WAvgCost = WAvgCost + (targetVolume - aggregateVolume) * chngeOnDay.Cells(numRows) / targetVolume

Once i have done this for all the possible combinations of days i then sum them together to see how much i would have made or lost if i had wanted to be 20% of the market and i had 100,000 shares to sell.

Sorry if this is in the wrong place i just really need some help.