Posts

Showing posts from February, 2024

MT5 Market order Buy and sell

 //buy   trade.SetExpertMagicNumber(MagicNumber); trade.Buy(lotsize,Symbol(),NormalizeDouble(SymbolInfoDouble(Symbol(),SYMBOL_ASK),_Digits),0,0,"Programetix Ea"); ///sell   trade.SetExpertMagicNumber(MagicNumber); trade.Sell(lotsize,Symbol(),NormalizeDouble(SymbolInfoDouble(Symbol(),SYMBOL_BID),_Digits),0,0,"Programetix Ea"); //exit buy all void close_buy_position()   {    for(int i=PositionsTotal()-1; i>=0; i--)      {       string currencypair=PositionGetSymbol(i);       int position_direction=PositionGetInteger(POSITION_TYPE);       int posmagic=PositionGetInteger(POSITION_MAGIC);       if(currencypair==Symbol() && position_direction == POSITION_TYPE_BUY&& int(posmagic) == int(MagicNumber))         {          int ticket=PositionGetTicket(i);          trade.PositionClose(ticket);   ...