Trade manually and by robot at the same time
-
As I may manually create some orders, I'm curious about how we can ensure that the robot recognizes the presence of these orders.
-
What do you mean?
-
@melnsee said in Trade manually and by robot at the same time:
As I may manually create some orders, I'm curious about how we can ensure that the robot recognizes the presence of these orders.
Excellent question! In MQL4, each order in MetaTrader has a unique identifier, known as an Order ID, which is automatically assigned when an order is opened. This ID is crucial for an EA to recognize and manage its own orders, especially in an environment where orders can also be placed manually.
To ensure that the EA specifically recognizes orders that it has generated, a common practice is to use the OrderComment() field to assign a custom tag or string to each order that the EA opens. For example, you could use "EA_BUYS" for buy orders and "EA_SELLS" for sell orders that your EA places. This way, when your EA reviews open orders, he can filter them by this specific comment and act only on the orders he himself has created.
And here example
-
@realjoker said in Trade manually and by robot at the same time:
@melnsee said in Trade manually and by robot at the same time:
As I may manually create some orders, I'm curious about how we can ensure that the robot recognizes the presence of these orders.
Excellent question! In MQL4, each order in MetaTrader has a unique identifier, known as an Order ID, which is automatically assigned when an order is opened. This ID is crucial for an EA to recognize and manage its own orders, especially in an environment where orders can also be placed manually.
To ensure that the EA specifically recognizes orders that it has generated, a common practice is to use the OrderComment() field to assign a custom tag or string to each order that the EA opens. For example, you could use "EA_BUYS" for buy orders and "EA_SELLS" for sell orders that your EA places. This way, when your EA reviews open orders, he can filter them by this specific comment and act only on the orders he himself has created.
And here example