How the EA algorithm works
In this chapter we will discuss how the algorithm works with the parts of your EA and how it will act.

Your EA’s modular system
Your EA consists out of modules the algorithm interacts with. It’s because of the modulairity that you are able to create any EA. The modules are divided into three categories:
- Modules which prevent opening
- Modules for opening
- Modules for closing
Read more about Modules. As you’ve seen in the image above, the algorithm will interact with one or more modules. In the next chapter we will go into detail about this.
Your EA’s behaviour
Your EA’s algorithm will behave differently depending on its state:
- There are no open orders
- There are one or more open orders
No open orders
When no orders are opened, all the EA does is wait for an Open Signal. When the signal activates, it will open an order, unless a Prevent Open module blocks it.

One or more open orders
When orders are open, your EA will evaluate if the open orders should be closed, based on if a SL/TP was hit or a Close Signal has activated. When SL/TP is hit, or a Close Signal actives, it will first check if a new order would be (hypothetically) opened after closing the current order. This is done by evaluating Open signals (taking into account Modules which prevent opening) and Close Signals. So, the same process, as when there are no open orders, is evaluated. If an order would (hypothetically) not be opened, the order will be closed. Also, the EA will evaluate if additional orders have to be opened. Additional orders will only be opened when an Open signal activates, thus after being inactive for at least 1 processed quote.

- An order is closed when its SL or TP is hit, or by a Close Signal. All Modules for closing can influence the order’s SL/TP. SL is set below the order (from a Buy perspective) and can only be moved up by the same, or another, module. The opposite is true for the TP: it can only potentially be moved down. SL/ TP values are currently not sent to the broker.
- An order is only closed if the order wouldn’t be opened again directly after closing, because if the algorithm would close the order, another order would be opened immediately and you would lose another round-trip of commission/ spread. To validate if this is the case, the Open Signal is re-evaluated before closing, also taking into account Prevent Open modules. F.e., when an order has to be closed seconds after opening, it’s very likely the Open Signal is still active. This can be countered by using a Prevent Open module, like the Time gap between orders module. When doing so, the Open Signal will be blocked, after closing the order, so the order can be closed.
- When using the Multiple order Open module additional orders are opened when the Open Signal has switched from active (which opened the previous order) to inactive and activates again, now opening an additional order.