Accumulating Profit and Loss.

 

Good afternoon.

I need to create a function where I accumulate the profits and losses of each trade and thus determine whether or not my robot continues to operate.

Ex:

if my profit is $ 100.00 positive or $ 100.00 negative I stop trading that day.

If anyone has an example of a role or where I look, I appreciate it.

 

You can use AccountInfo() and a static variable to store the daily beginning balance and stop trading if (not tested or verified):

static double balOpen;
if (BeginOfDay) { // however you defines this
        balOpen = AccountInfoDouble(ACCOUNT_BALANCE);
} else if ( fabs(AccountInfoDouble(ACCOUNT_BALANCE) - balOpen) > 100.0 ) return 

BTW to search for functions use this table: https://www.mql5.com/en/docs/function_indices

It offers a kind of search for keywords.

Documentation on MQL5: Account Information / AccountInfoDouble
Documentation on MQL5: Account Information / AccountInfoDouble
  • www.mql5.com
AccountInfoDouble - Account Information - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Reason: