One Trade EA Help needed

 

Hi, Can anyone let me know the code to make an EA place only one trade a day. If it has opened a trade then irrespective whether it wins or loses that trade it must not open another trade. Many thanks

 
hoosain:
Hi, Can anyone let me know the code to make an EA place only one trade a day. If it has opened a trade then irrespective whether it wins or loses that trade it must not open another trade. Many thanks

Very simple to do. What are the conditions of the trade?

 

Use this:

First put this up at the top:

int DayOfLastTrade;

Then where you are sending your order in, put this around it:

if (TimeDayOfYear(TimeCurrent())!=DayOfLastTrade)

{

ticket=OrderSend(....

DayOfLastTrade=(TimeDayOfYear(TimeCurrent());

}

That should only allow it to make one trade per day. Hope that is what you wanted.

 

I've tested it...this doesn't work!

 

The problem with that approach would be if you change time frames, have a system crash or power outage etc.

What I do is check the orders total and orders history total. You'd create your own functions and pass in the current day and year. Then check to see if there's either a current open order or one exists in history for the current day and year.

Hope that helps.

Lux

 
luxinterior:
The problem with that approach would be if you change time frames, have a system crash or power outage etc.

What I do is check the orders total and orders history total. You'd create your own functions and pass in the current day and year. Then check to see if there's either a current open order or one exists in history for the current day and year.

Hope that helps.

Lux

Thanks my friend!

Reason: