One Entry Per Bar....

 

Hi Guys,

what can I put into an EA so that when the conditions meet it only opens 1 order and if the order is closed (TP has reached) no matter if the conditions meet again..should not open another order...

Thanks

Babar

 
babarmughal:
Hi Guys,

what can I put into an EA so that when the conditions meet it only opens 1 order and if the order is closed (TP has reached) no matter if the conditions meet again..should not open another order...

Thanks

Babar

Yes, i want to know too. If we can do this then we can just make an EA base on some stadart simple indicator.

 
harryhid:
Yes, i want to know too. If we can do this then we can just make an EA base on some stadart simple indicator.

i know how to do it in a spreadsheet but I'm afraid I don't know how to tell you to do it in code but there is probably more than one solution that will work if you know how to do it. Can you write a code to detect if a position is already open? What can you detect about the account with code? Can you tell when the last order was opened, what the available margin is? Something about the account that you CAN detect which will be obviously different if a position is already open?

 
harryhid:
Yes, i want to know too. If we can do this then we can just make an EA base on some stadart simple indicator.

https://www.mql5.com/en/forum/172983/page3

found this on the site...would this help?

 
babarmughal:
Hi Guys,

what can I put into an EA so that when the conditions meet it only opens 1 order and if the order is closed (TP has reached) no matter if the conditions meet again..should not open another order...

Thanks

Babar

one entry per bar :

if(Time[0] > LastTime)

{

TradeThisBar = true;

LastTime = Time[0];

}

...

if(EntryCondition && TradeThisBar)

{

if(OrderSend(......) > 0) TradeThisBar = false;

}