How to open one order at a time?

 

How do i make the program to open only one trade, and if a trade is open, not to open another one?

 
msbusinessil wrote >>

How do i make the program to open only one trade, and if a trade is open, not to open another one?

That is a simple matter of telling the platform to open your trade only once.

Check to see if the trade has been opened and if it has then stop execution.

 

OrdersTotal() will be greater than 0 if there are open or pending trades.

Test that and do something.

// Take a new trade?

if(OrdersTotal() != 0)) ... don't open a new trade...

 
Thanks for the quick answer. and sorry for the ignorance. i'm a real newbie..
Can you please give me the function name (the one that checks for open trades), or give me a link for explanation in the site/book?
 

maybe there is a function which returns the amount of open orders.

maybe if this function returns more than 0, that there is already an open order.

maybe RTFM is useful.

 
Thanks guys! i'll be trying it right away!
 
meikel:

maybe there is a function which returns the amount of open orders.

maybe if this function returns more than 0, that there is already an open order.

maybe RTFM is useful.

It's slightly more complex than that if msbusinessil means that there should only be one trade from his/her EA, rather than one trade in total. But it's still a question which has already been asked and answered 9,432 times on this forum.

 
msbusinessil:
Thanks for the quick answer. and sorry for the ignorance. i'm a real newbie..
Can you please give me the function name (the one that checks for open trades), or give me a link for explanation in the site/book?

i think the help you need cant given to you in this forum.

phy has already told you the function, as kindly as he is.

dont trade, dont program is the best advice i can give to you

 
jjc:

It's slightly more complex than that if msbusinessil means that there should only be one trade from his/her EA, rather than one trade in total. But it's still a question which has already been asked and answered 9,432 times on this forum.

yes, if you run multiple instances of EAs on different charts.

but i dont think that such a nonprogrammer try to programm an multi-instance-capable EA.

 
meikel:

but i dont think that such a nonprogrammer try to programm an multi-instance-capable EA.

What if he/she has already bought a commercial EA and is now trying to write one of his/her own to run alongside it? There are many reasons why "one order at a time" might not mean "OrdersTotal() == 0".

 
jjc:

What if he/she has already bought a commercial EA and is now trying to write one of his/her own to run alongside it?

that would be like i buy a VW Golf and try to make a Mercedes from it.

without knowing how to weld, how a combustion engine works and so on...

Reason: