I know that this has been covered in other questions here but I'm not sure what's happening in my case. My code is returning a compiler error "Stack too deep, try removing local variables." But I only have around five function arguments and a few more local variables. The function in question is given below:
function sell(bool limit, uint256 whichquery, uint8 whichoutcome, uint256 amount, uint16 price) {
uint cumulativeamountgained;
uint numorderstobedeleted;
uint amountnotfilled = amount;
if(tokenHoldings[msg.sender][whichquery][whichoutcome] < amount) throw;
if(limit){
for (uint i=orderbook[whichquery][whichoutcome][0].length-1;i>=0;i--){
if(orderbook[whichquery][whichoutcome][0][i][0] >= price) {
if(orderbook[whichquery][whichoutcome][0][i][1] > amountnotfilled){
orderbook[whichquery][whichoutcome][0][i][1] -= amountnotfilled;
tokenHoldings[address(orderbook[whichquery][whichoutcome][0][i][2])][whichquery][whichoutcome] += amountnotfilled;
The error is triggered on the last line of this code snippet under the first "whichquery".