English

## Partial Close Odd Lot

 3 andreforex 2016.01.27 00:45   Hi, anyone could help me with my EA that close parial open trades when it reach a X% in profit and move SL to BE, but when lot is nod divisable by 2 like 0.03 its only moves to BE and don`t close partially.```extern double  Percent_Break = 1;// Risk Reward to close partial extern double  Percent_RealizacaoParcial = 50;//% of open open position ``` ```double openPrice, stopPrice, BE_Pips, StpB, StpS, CalculoRP, TamanhoLot, CloseLot;          CalculoRP = 100/Percent_RealizacaoParcial;//Partial calc          int total=OrdersTotal();     for (int cnt=0;cnt openPrice && Ask<= StpS && OrderSymbol()==Symbol())         {                               if (StringFind(Coment, "from #", 0) == -1)            {             OrderClose(OrderTicket(), CloseLot, Ask, 0);                         }            OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),MagicNumber);            if(!WindowScreenShot(StringConcatenate("Trades\\"+Symbol(),"_",OrderType(),"_",Period(),"_",TimeToStr(TimeCurrent(),TIME_DATE),"_",Hour(),".",Minute(),".png"),1920,768)) Print(GetLastError());         }           else         {                      if(mode == OP_BUY && stopPrice < openPrice && Bid>= StpB && OrderSymbol()==Symbol() )                {                      if (StringFind(Coment, "from #", 0) == -1)                      {                         OrderClose(OrderTicket(), CloseLot, Bid, 0);                      }                                     OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),MagicNumber);                if(!WindowScreenShot(StringConcatenate("Trades\\"+Symbol(),"_",OrderType(),"_",Period(),"_",TimeToStr(TimeCurrent(),TIME_DATE),"_",Hour(),".",Minute(),".png"),1920,768)) Print(GetLastError());                }                }       }       }   } ```Thanks, i`m learning so i`m sorry for this question :D
 12983 WHRoeder 2016.01.27 03:28 #   andreforex: t close parial open trades when it reach a X% in profit and move SL to BE, but when lot is nod divisable by 2 like 0.03The amount closed and the remaining amount must both be at least min lot and a multiple of lot step; close 0.02 and keep 0.01 or visa versa. See my code
 210 edddim 2016.01.27 20:03 #   I found (maybe I haven't searched enouqh) that
12983
WHRoeder 2016.01.27 21:00 #

 edddim: :In Modify instead of OrderOpenPrice() should be Ask, since it could be lower than the open price.. You can not change the open price of an open order; only pending orders.

 12983 WHRoeder 2016.01.27 21:49 #   You can't place the SL at Ask (or for buy, the Bid) because 1) it would be triggered immediately and 2) doesn't abide by the limits Requirements and Limitations in Making Trades - Appendixes - MQL4 Tutorial
 210 edddim 2016.01.27 22:55 #    ( haven't checked other variables :( )```if(mode == OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber() == MagicNumber && stopPrice > openPrice && Ask<= StpS ) {   double part_Lots = NormalizeLotsByPercent(TamanhoLot, Percent_RealizacaoParcial);   OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0);   bool close_only_part = OrderClose(OrderTicket(), part_Lots, Ask, 0); } ``` As alternative solution.Edit modified.