# How to take only one action on lots per condition??? - page 2

227

now it doesn't divide the lot
Moderator
10536

micoul81:
now it doesn't divide the lot

Why do you divide the lot and then multiply it by 2?

`OrderClose(OrderTicket(), Dividelot*2, Bid, 3, Red);`
227

```  void PartialClose()
{
double Lotstep = MarketInfo(Symbol(), MODE_LOTSTEP);
int x = 0; if(Lotstep == 0.01) x = 2; else x = 1;

for(int i = OrdersTotal()-1; i >= 0; i--){
if( Magic == OrderMagicNumber() )
{
int Tk=10;
double LOTS = OrderLots();
double Dividelot = NormalizeDouble(LOTS * 0.5, x);

if(Bid > OrderOpenPrice()+(Tk*Point)){
OrderClose(OrderTicket(), Dividelot, Bid, 3, Red);
}
}
if(OrderType() == OP_SELL){
}
}
}
}

}
```

Sorry it's an error when i paste the code , still have the same problem

16761

micoul81: it continue to divide lots
micoul81Sorry it's an error when i paste the code , still have the same problem
```int x = 0; if(Lotstep == 0.01) x = 2; else x = 1;
double Dividelot = NormalizeDouble(LOTS * 0.5, x);```
1. You still have the same problem (multiple closings) because you didn't do anything about it. Asked and previously answered.
2. This assumes lotstep must be a (negative) power of 10 (0.1 or 0.01) and fails for any other value. Don't assume, do it right, see my NormalizeLots.
370

micoul81:

Sorry it's an error when i paste the code , still have the same problem

Hello micould81,

did you manage to fix your code? could you let me know where and how you implemented your PartClose function in the main EA? I have tried but I cannot managed to get the EA to loop in and through the partClose function?

thanks

1100

fabio_geraci:

Hello micould81,

did you manage to fix your code? could you let me know where and how you implemented your PartClose function in the main EA? I have tried but I cannot managed to get the EA to loop in and through the partClose function?

thanks

You could also try following the suggestions here, go through your code and try to see in yours something similar is happening, and try to correct it as WHRoeder and GumRai are telling micould81 to do.  I know your code is not likely to be exactly the same, but it is a starting point.  Then, if you are able to fix your code, you could also post a before and after here, so people can see what was wrong, and what you did to fix it.
370

JD4:
You could also try following the suggestions here, go through your code and try to see in yours something similar is happening, and try to correct it as WHRoeder and GumRai are telling micould81 to do.  I know your code is not likely to be exactly the same, but it is a starting point.  Then, if you are able to fix your code, you could also post a before and after here, so people can see what was wrong, and what you did to fix it.

JD4,

I have tried several approach mostly based on the work of Mr. Hopwood. the problem is that the PartClose function doesn t get call so I have tried micould81 approach, keeping the start() as it is now, and same issue, that is the reason of my question, where should i put the call for the partClose function. As it stands atm.

```int start()
{
//----
if (OrdersTotal() == 0)
{
TicketNo = -1;
}//if (OrdersTotal() == 0)
if (OrdersTotal() > 0)
{
//{
//   if (OrderProfit() > 0)
}//if (OrdersTotal() > 0)
if (TicketNo == -1)
{
//if(timeprev==Time[0]) return(0);
//timeprev=Time[0];