profit loss not being recorded

manjit-s  

Dear Sirs, Again, your help requested.

I developed an EA. The EA has entry via TRADE DEAL and even exit via TRADE DEAL. That is no take profit or Stoploss.

While executing the trade, there were entry and exit orders, but no profit / loss was recorded/

Same happened when I closed open position using "PositionClose()".

Kindly help guiding, where I am wrong.

Screenshot as below.


//Buying order
   if(Open_Buy_present && Exitbuy1)
     {

      ZeroMemory(mrequest);
      ZeroMemory(mresult);

//      ulong Open_ticket = PositionGetInteger(POSITION_TICKET);
//      mtrade.PositionClose(Open_ticket);

              ulong Open_ticket = PositionGetInteger(POSITION_TICKET);
              string Open_Symbol = PositionGetString(POSITION_SYMBOL);
      
              mrequest.action = TRADE_ACTION_DEAL;
              mrequest.symbol = Open_Symbol;
              mrequest.position = Open_ticket;
              mrequest.type = ORDER_TYPE_SELL;
              mrequest.price = latest_price.bid;
              mrequest.type_filling = ORDER_FILLING_FOK;
              mrequest.volume = Lotsize;
              mrequest.magic = EA_Magic;
      
      // Sending closing order
            bool Closing_Buy_Order = OrderSend(mrequest,mresult);
     
      //buy closing order trading result
      if(mresult.retcode == 10008 || mresult.retcode ==  10009)
        { Alert("A Closing Order for open buy position is placed against ticket : ", mresult.order);  }
      else
        {
         Alert("Sell Order for open Buy position cannot be placed : ", GetLastError());
         ResetLastError();
         return;
        }
     }
   if(Buycondition1 && Buycondition2 && Buycondition3)
     {
      if(Open_Buy_present)
        {
         Alert("Cannot Buy, Buy position already open");
         return;
        }

      mrequest.action = TRADE_ACTION_DEAL;
      mrequest.symbol = _Symbol;
      mrequest.type = ORDER_TYPE_BUY;
      mrequest.volume = Lotsize;
      mrequest.price = latest_price.ask;
      //      mrequest.sl = latest_price.ask - STP;
      //      mrequest.tp = latest_price.ask + TKP;
      mrequest.type_filling = ORDER_FILLING_FOK;
      mrequest.magic = EA_Magic;

      // Sending buy order
      bool Buy_Order = OrderSend(mrequest, mresult);
      
      // buy order trading result
      if(mresult.retcode == 10008 || mresult.retcode ==  10009)
        { Alert("A buy Order has been placed against ticket : ", mresult.order);  }
      else
        {
         Alert("Buy Order cannot be placed : ", GetLastError());
         ResetLastError();
         return;
        }
     }
  }
//+------------------------------------------------------------------+
Files:
screenshot.jpeg  454 kb
Reason: