Make my EA stop after DailyProfit has been reached

 

If anyone can help I would be so greatful. I have an EA but it constantly makes plenty of orders during the day. I wish to add the code to make it stop trading after it has reached a total DailyProfit of $10. It should reset every day so tomorrow it also makes only $10 and then stop trading for the rest of the day.

This is the code

int myOrderSend(int type, double price, double volume, string ordername) 

  {

   if(!IsTradeAllowed()) 

   return(-1);

   int ticket = -1;

   int retries = 0;

   int err = 0;

   int long_trades = TradesCount(OP_BUY);

   int short_trades = TradesCount(OP_SELL);

   int long_pending = TradesCount(OP_BUYLIMIT) + TradesCount(OP_BUYSTOP);

   int short_pending = TradesCount(OP_SELLLIMIT) + TradesCount(OP_SELLSTOP);

   string ordername_ = ordername;

   if(ordername != "")

      ordername_ = "("+ordername+")";

   //test Hedging

   if(!Hedging && ((type % 2 == 0 && short_trades + short_pending > 0) || (type % 2 == 1 && long_trades + long_pending > 0)))

     {

      myAlert("print", "Order"+ordername_+" not sent, hedging not allowed");

      return(-1);

     }
 
Jack Rock: if anyone can help I would be so greatful. I wish to add the code to make it stop trading after it has reached a total DailyProfit of $10.
  1. Your posted code is irrelevant.

  2. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your difficulty.
              No free help (2017)

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum (2018)

    We're not going to code it for you (although it could happen if you are lucky or the issue is interesting).
              No free help (2017)

  3. There are several ways. The easiest is on the start of a new day, remember the account balance. Before opening, compare the current balance to remembered one and don't open.
              Please help with one trade per day code - Day Trading - Expert Advisors and Automated Trading - MQL5 programming forum #3.2 (2020)



Reason: