Given a list of buy/sell orders and previous trades, compute a buy/sell price I'm using the Cryptsy API with a bot. So far, my bot's problem is that when it decides it needs to buy or sell a coin (not just bitcoin), I always seem to compute a price that is way too low or high. The data I have access to is:


The currently outstanding buy orders (though a few seconds old and without timestamps)
The currently outstanding sell orders
The previous 20 trades that were executed on the market


From all of this data, is there an existing algorithm to compute a price that will almost always buy or sell? My bot's priority is to have fast trades(like, less than a minute for execution), even if the price is not the best. 

Cryptsy themselves compute a pretty good number in their web UI (the default ask/bid price), but I don't see that value exposed in their API. Where does this ask/bid price come from? 

For reference, I've tried a few things with little success


Highest buy price/Lowest sell price -- This tends to catch outliers and results in me placing an overly optimistic bid that only one buyer/seller was willing to pay (and because my data is seconds old, apparently somone else picks it up) 
An average of 3 lowest/highest -- This had the same problem with outliers
Lowest buy price/Highest sell price -- This is extremely pessimistic and results in me paying ridiculous prices that are unreasonable 


How can I compute a good ask/bid price from this set of data I have?
I had been thinking about this lately and haven't explored this option at ALL but I'm thinking out loud here because nobody has replied in 8 days.

So what if you took the average of the top orders 1 - 5, then the average of the top orders 2 - 6, the average of 3 - 7, ect. Out of THOSE orders you then calculated the average again to arrive at your sell point? The process could be repeated as nessecary to find an average of averages that hover around the top of the buy points.

Thoughts?