mql - How to enter a new order only if / when the first one has been executed (filled)? [MQL5] -
i'm kinda of new in mql5.
i have ea buys 1 stock first (let's petr4) , buys 1 (let's abev3).
the problem can order second 1 when first 1 executed (not placed).
i used mqltraderesult.retcode
return number, shows if order has been placed , need know if order has been filled in order continue second operation.
can me? thanks
such indication ought coded in positionselect()
call:
first call
if ( positionselect( "petr4" ) ) { ... /* further work go here */}
this chooses open position further working it. returns
true
if function completed. returnsfalse
in case of failure.
if there active position reported given symbol, further work go ahead inside {...}
-code-block
the hidden magic in fact, there either single-position symbol, or none @ all. makes rest of logic crystal-clear.
execution of trade operations results in opening of position, changing of volume and/or direction, or disappearance. trade operations conducted based on orders, sent
ordersend()
function in form of trade requests. each financial security (symbol) 1 open position possible. position has set of properties available readingpositionget...()
functions.
...
position_ticket
unique number assigned each newly opened position. matches ticket of order used open position except when ticket changed result of service operations on server, example, when charging swaps position re-opening. find order used open position, applyposition_identifier
property.
position_ticket
value correspondsmqltraderequest::position
.
Comments
Post a Comment