Help daily profit

 
My EA has to stop trading if a certain daily profit amount is reached and starts trading on the next day again. How can I program ?
 

Hi please press this button:


 

this is my code

if (AccountBalance()<AccountBalance()+4000)

As reset, AccauntBalanc (), every new day ?

 
ea_mt4:

this is my code

if (AccountBalance()<AccountBalance()+4000)

As reset, AccauntBalanc (), every new day ?

Can never work.

Please see:

Account Information

Functions that return parameters of the current account.

Function

Action

AccountInfoDouble

Returns a value of double type of the corresponding account property

AccountInfoInteger

Returns a value of integer type (bool, int or long) of the corresponding account property

AccountInfoString

Returns a value string type corresponding account property

AccountBalance

Returns balance value of the current account

AccountCredit

Returns credit value of the current account

AccountCompany

Returns the brokerage company name where the current account was registered

AccountCurrency

Returns currency name of the current account

AccountEquity

Returns equity value of the current account

AccountFreeMargin

Returns free margin value of the current account

AccountFreeMarginCheck

Returns free margin that remains after the specified position has been opened at the current price on the current account

AccountFreeMarginMode

Calculation mode of free margin allowed to open orders on the current account

AccountLeverage

Returns leverage of the current account

AccountMargin

Returns margin value of the current account

AccountName

Returns the current account name

AccountNumber

Returns the current account number

AccountProfit

Returns profit value of the current account

AccountServer

Returns the connected server name

AccountStopoutLevel

Returns the value of the Stop Out level

AccountStopoutMode

Returns the calculation mode for the Stop Out level

AccountInfoDouble - Account Information - MQL4 Reference
AccountInfoDouble - Account Information - MQL4 Reference
  • docs.mql4.com
AccountInfoDouble - Account Information - MQL4 Reference
 

I have corrected the code, the new code is

If (.... && AccountBalance () <10007) works, but remains the problem of daily profit. Es. I want you to earn $ 5 a day

So 10007$ stops working, but the next day must resume
 

I do not believe you.

If (.... && AccountBalance () <10007) 

This does not work.

It does not even compile.


 

Replace the points with a proper statement

Es.  Open [0]> Open [1]

 

Maybe you can actually post some code yourself .

 

Add the profit/loss of all trades that have been opened today.

If profit > n

  Close all trades (if necessary)

  Do not open any new trades until  tomorrow.


   datetime midnight=TimeCurrent()-(TimeCurrent() % 86400);
   datetime midnight_tonight=midnight+86400;


 
Keith Watford:
   datetime midnight=TimeCurrent()-(TimeCurrent() % 86400);
   datetime midnight_tonight=midnight+86400;
Or write functions, making the code self-documenting Draw rectangle around range of bars by hours - MQL4 and MetaTrader 4 - MQL4 programming forum
 
Am also interested in this topic, but the best idea is close all trade if a certain profit is made or if TP/SL is hit and open trade again tomorrow.
Reason: