Error 131. Cant understand Why and i have read a lot about it. Please help.
Hi,
Im getting the following message, and ill attach the function that closes the order also...
And the function:
You have to be sure that the position size you are trying to close is >= Min Lot and a multiple of Lot Step
What is reporting the error ? OrderCloseReliable ? is it doing it correctly ?
- The amount trying to close is >= min lot and I think the amount remaining must also be >= min lot.
- investguy:After you close 0.11 out of 0.14 the remaining will be 0.03. What is minlot?
2013.11.28 05:49:52 2012.12.21 12:40 Yoda GRInD v1.2 EURUSD,M1: OrderTicket() = 13 CloseBuyLot = 0.11 2013.11.28 05:49:49 2012.12.21 12:10 Yoda GRInD v1.2 EURUSD,M1: open #13 buy 0.14 EURUSD at 1.32171 ok
- You are using NormalizeDouble(..., LotDigits) This assumes that lotStep is a multiple of 10 (0.1/0.01) and fails for any other. Do it right.
- The amount trying to close is >= min lot and I think the amount remaining must also be >= min lot.
I have found the problem but still cant understand the reason for the problem.
Here is the problem.. In this part:
SmartEPBuy(); if (SumOfSell > 2) CloseSellLot = OrderLots();
OrderLots() assume a completely different value to the one previously selected by OrderSelect.
Here is SmartEPBuy:
void SmartEPBuy(){ double TotalLot = 0; SumOfSell = 0; for (int e = OrdersTotal(); e >= 0 ; e--) { if ( OrderSelect(e,SELECT_BY_POS, MODE_TRADES) && OrderSymbol()==Symbol() && ((OrderMagicNumber()==Magic ) || (OrderMagicNumber()==Magic +4 )) ){ if(OrderType()==OP_SELL){ TotalLot = OrderLots() + TotalLot; SumOfSell++; } } } TotalLotS = TotalLot ; if (TotalLot >= EPTotalLotMult*LotsOptimized()) { //(TotalLot >= ((EPTotalLotMult-1)*LotsOptimized())) SmartEPBuy = true; EPUmbrellaBuy = TotalLot ; //return; } else { SmartEPBuy = false; EPUmbrellaBuy = 0; } }
Could it be that the OrderLots() is using the OrderSelect from inside of this function ?
Noted Sir! Thank You for the insights.
Very appreciated.
Hi,
Im getting the following message, and ill attach the function that closes the order also...
And the function: