Break-Even

This EA can be used alongside other EAs to manage order closures, with specific functions detailed in the "Terminology" section below. For example, in MT4, open two EURUSD charts: load an EA for placing orders on one chart and this EA on the other. When the order-placing EA generates an order that reaches the profit target, this EA adjusts the stop loss to lock in profits.

The "Order Magic Number" parameter of this EA defaults to 0, meaning it operates on all orders for the symbol. If a number greater than 0 is entered, the EA will only manage orders placed by an EA with the same "Order Magic Number."

Terminology

Order Magic Number: When multiple order-placing EAs are loaded for the same symbol, each EA must have a unique number in its "Order Magic Number" parameter to distinguish its orders. This prevents logical errors by allowing EAs to identify and manage their respective orders.

Points: 1 point corresponds to the last decimal place of the symbol's price. For a 5-decimal price, 1 point is 0.00001; for a 4-decimal price, 1 point is 0.0001.

Break-Even:

  • Parameters: Parameter A [Profit Points to Trigger], Parameter B [Profit Points to Lock]
  • Function: When an order’s profit reaches or exceeds the points specified in Parameter A, the stop loss is set to lock in the profit specified in Parameter B. (Parameter B must be less than Parameter A.)
  • Example: Parameter A = 100, Parameter B = 5. For a BUY order opened at 1.00001, if the price rises to 1.00101 (a profit of 100 points, meeting Parameter A), the stop loss is moved to 1.00006 (entry price plus 5 points, Parameter B) to lock in at least 5 points of profit.
  • Note: For BUY orders, the stop loss is only adjusted upward; for SELL orders, it is only adjusted downward.
  • Disable: Set Parameter A [Profit Points to Trigger] to 0 to disable this function.
  • Requirement: Parameter A must be greater than Parameter B, and the difference must exceed the MT4 platform’s minimum required distance between the current price and stop loss, or the setting will fail.

One-Time Break-Even: If enabled, this instruction applies the break-even stop loss adjustment to an order only once. If this option is enabled, this instruction should be placed before the order-placing module to clear stored order status information when no orders are open.

Partial Closure: In MT4, if an order is partially closed, the remaining portion is treated as a new order by this EA.