How EA can take a position not more than once per day

 

I want to code an EA that runs continuously but takes a position not more than once per day, and am interested in how others have logically approached this. My current logic is:

if P == 0 (and other conditions are met) then take a Position and set P = 1

if current time < previous time then set P = 0

I believe this logic will work, but am interested to know if anyone 1) thinks it won't work and/or 2) has other/better logic. Thanks in advance.

 
rdone:

I want to code an EA that runs continuously but takes a position not more than once per day, and am interested in how others have logically approached this. My current logic is:

if P == 0 (and other conditions are met) then take a Position and set P = 1

if current time < previous time then set P = 0

I believe this logic will work, but am interested to know if anyone 1) thinks it won't work and/or 2) has other/better logic. Thanks in advance.

It all depends on your strategy.

If for you it is right, so it is right...

If you don't know ho to program this, you should go to the Freelance section...

https://www.mql5.com/en/job

Trading applications for MetaTrader 5 to order
Trading applications for MetaTrader 5 to order
  • www.mql5.com
It's a very easy and simple task. I just want to automate a strategy that I have into an EA. Please be very skillful, knowledgeable and a true Coding Ninja!  Please get at me ASAP because I want to start right now! This strategy is rather uncomplicated and PriceAction based. Bollinger band Space should be split in 3 equalspaces These...
 
rdone:

I want to code an EA that runs continuously but takes a position not more than once per day, and am interested in how others have logically approached this. My current logic is:

if P == 0 (and other conditions are met) then take a Position and set P = 1

if current time < previous time then set P = 0

I believe this logic will work, but am interested to know if anyone 1) thinks it won't work and/or 2) has other/better logic. Thanks in advance.

What I meant was, instead of the Boolean logic, explain your trading strategy... Otherwise I doubt people here can help you...
 
It will work if you use D1 candles.
 

You can also check your trade history to see if a trade already has been triggered for the day.

The date time can be made into a unique day string format (dd-mm-yyyy) and be used to check against the trade history iterated from present to past.

I have done the code, and the above method is the solution I have used.

Reason: