close percent ea

Mr Anucha Maneeyotin  

Hi Elliot Debonee


Please try use this code

void CloseProfitPartial()
  {
   for(int i = 0; i < PositionsTotal(); i ++)
     {
      if(eaposition.SelectByIndex(i))
        {
         string PosSymbol        = eaposition.Symbol();
         double Profit           = eaposition.Profit();
         ulong ticket            = eaposition.Ticket();
         double volume           = eaposition.Volume();
         string comment          = eaposition.Comment();
         if(Profit >= TargetProfit && PosSymbol == _Symbol && volume > 0.01)
           {
            eatrade.PositionClosePartial(ticket,volume / 2);
           }
        }
     }
  }
Elliot Debonee
Elliot Debonee
  • 2021.08.29
  • www.mql5.com
Trader's profile
Reason: