How an EA knows if there is an opened position?

 

Hello to everybody.

I have a question . how an EA knows if there is an opened position?
I have searched for this issue in the site but I didn't find nothing about it.
I'm developing an EA that works only with market orders because I want be sure that the trade will be take place. But sometimes, for any reason, the trade doesn't performs and my idea is that the EA "knows" this, for sending a new order again if the previous wasn't did it..
There is a code for knowing this?

Thanks to who answer me and excuse my horrible English and greetings from Argentina

Betowm

 
Betowm: I have searched for
Not very well. https://www.mql4.com/search#!keyword=orderselect%20loop
 
WHRoeder:
Not very well. https://www.mql4.com/search#!keyword=orderselect%20loop


Thank you for your response WHRoeder, but I have gone to the link you gave me and still I don't find what I need: a way to make the EA to know that there is an open position or not. Unless I am blind, still I didn't found this information.... Best regards and thank you again.

Betowm

 
Betowm:


Thank you for your response WHRoeder, but I have gone to the link you gave me and still I don't find what I need: a way to make the EA to know that there is an open position or not. Unless I am blind, still I didn't found this information.... Best regards and thank you again.

Betowm


Using OrdersTotal and OrderSelect is the most basic code and it is unbelievable that you have not used it in your practice EAs

https://book.mql4.com/trading/orderclose

https://book.mql4.com/trading/ordermodify

https://book.mql4.com/samples/expert

 
GumRai:


Using OrdersTotal and OrderSelect is the most basic code and it is unbelievable that you have not used it in your practice EAs

https://book.mql4.com/trading/orderclose

https://book.mql4.com/trading/ordermodify

https://book.mql4.com/samples/expert


Thank you very much GumRai. Take in mind that I'm a newbie in programming, otherwise never had I done this question.

Best regards from Argentina :-)

Betowm