I want only one trade per day !

 

Hi all,

I develop my first expert advisor. I've just a small problem. I don't want more than one BUY order and SELL order per day.

By example, if I have a signal for open a Buy order : It won't be open if a Buy order was opened during the day (00h00 GMT ==> 00h00 GMT) and it's the same thing for the short position : if I have a signal for open a Sell order, it won't be open if a Sell order was opened during the day.

So the EA can open only one Buy order and only one Sell order per day.

How to develop that ??

Thank you

Max

 

example

example.......

Files:
gbp9am.mq4  8 kb
 
maxime_mataf:
Hi all,

I develop my first expert advisor. I've just a small problem. I don't want more than one BUY order and SELL order per day.

By example, if I have a signal for open a Buy order : It won't be open if a Buy order was opened during the day (00h00 GMT ==> 00h00 GMT) and it's the same thing for the short position : if I have a signal for open a Sell order, it won't be open if a Sell order was opened during the day.

So the EA can open only one Buy order and only one Sell order per day.

How to develop that ??

Thank you

Max

Max,

I just want to ask you, what if this order (Buy or Sell) hasn't been opened today (Ex: Yesterday)?

Do you want to open a new order in this case or you want to open only one order per chart?

Anyway, you can use something like this to check if the order has been opened today or not:

if(OrderSelect(1, SELECT_BY_POS)==true)

{

if(TimeToStr(OrderOpenTime(),TIME_DATE ) != TimeToStr(CurTime(),TIME_DATE ))

{

//open new order

}

}

 

Hi,

I want maximum : one Buy order and one Sell order per day and per chart.

So, in one day and on one chart, we can have :

1. no order

2. one Buy order

3. one Sell order

4. one Buy order and one Sell order.

That's all the possibilities.

I don't know if you have understand, I know my english is very bad so it's not simple to explain for me...

This is an extract from my EA : If you can help me...

Thx

int total=OrdersTotal();

if(total<1)

{

if(AccountFreeMargin()<(1000*Lots))

{

Print("Votre capital est insufisant. Votre marge est de ", AccountFreeMargin());

}

if(Ask==....blablabla
 

Anybody can help me ?

I don't know how to do that !

There should not be new order if there were an order opened since 00h00. I don't know if you understand...

Reason: