Previous page: Part 3 : Signals.

Tutorial - Part 4: Modules

Last update: 14th May 2023

With the signals added to your EA, your EA will now open and close orders. Two more tasks remain: setting the alternative take profit to PSAR, in case the target is less than 5 pips away and secondly, setting the stop loss equal to the value of PSAR as well. To do this, we will have to add the Take profit - Conditional (Pro) and the Stop loss - Conditional (Pro) module twice, once for buy and once for sell. So we will end up with 4 close modules: 2 times for take profit and 2 times for stop loss.

When adding any module to your EA, check the right side of the screen for an explanation of how the module works and how to configure it.

To add the Take profit - Conditional (Pro) module, click 'Add' in the Strategy part of the EA's main screen.

add module
Click the 'Add' button of your EA's Strategy section.

You will now see a list of all modules you can add to your EA. We're going to add the Take profit - Conditional (Pro) module, which is one of the most advanced modules. After clicking Add, you're looking at the list of modules:

add take profit module
Click the Take profit - Conditional (Pro) module.

You now need to enter the modules' parameters. We will want to enter a name and other basic settings first:

  1. Name: Buy TP
  2. Enabled for: Is Enabled For Buy Order (to only enable this module for buy orders)
We will then define the precondition, which means the condition which has to be met before the TP will be set. Since we only want the take profit to be set when the difference between the order's open price and the target is less than 5 pips away, we will apply the same logic as the previous page of this tutorial to do so. Also, we will set the TP to the value of PSAR only if PSAR is below the current price, so the direction of the price is up. So, in short, if the price is moving up, we will check if the remainder of open price modulo 50 pips is bigger than 45 pips:

take profit precondition
The precondition of Take profit - Conditional (Pro) for buy orders

Next, we're going to set the value of take profit to the value of the order's open price + the distance to PSAR:

take profit value
The value of Take profit - Conditional (Pro) for buy orders

We will not enter a condition when to remove the take profit, so we will leave the last condition empty. We do however set the last values:

  1. Trail distance (pips): 0
  2. Trail step size: 0
  3. Close percentage: 100

We will also add the same Take profit - Conditional (Pro) for sell orders. Here's how we set it up:

take profit sell
The Take profit - Conditional (Pro) module for sell orders

Now we will add the stop loss modules, which are easier to configure because they have a simple precondition: we simply always set the value of stop loss to the order's price minus PSAR, if PSAR is above the current price. So, the precondition (for buy) is if PSAR is above the current price. The start value is the value of PSAR.

stop loss buy
The Stop loss - Conditional (Pro) module for buy orders

And for sell, the precondition is the opposite, but everything else is the same:

stop loss sell
The Stop loss - Conditional (Pro) module for sell orders

If you want to know more about Modules and what they're capable of, please check the in-dept Modules documentation. You will be surprised about the flexibility you can create by using modules. To see an example, check out this blog: How to set stop loss based on the ATR indicator?

Next: Part 5 : Summary.