Example
This page provides an example of configuring the oscillator engine, including all six oscillator submodules. The configuration process is carried out step-by-step, utilizing certain oscillator submodules to generate trading signals, while others are used as trend filters. All chart examples provided can be easily replicated using the example packages offered. Alternatively, all necessary changes to the input parameters can be located in the illustration captions provided in the chart examples.
Concept diagram
The concept diagram provided below depicts the function block associated with this page.
Reset of inputs
Locate the Expert Advisor Builder application in the dropdown menu of the strategy tester settings under FEA Trading\MT4\Expert Advisor Builder 2.0 if you're using a MetaTrader 4 instance or FEA Trading\MT5\Expert Advisor Builder 2.0 if you're using a MetaTrader 5 instance. You can replicate the entire example in minutes by following the steps outlined in this article. To begin, kindly reset the strategy tester input as indicated.
The default input parameters of the Expert Advisor Builder are designed to be highly functional. This implies that not every parameter needs to be adjusted when creating a new strategy. Instead, only the differences from the default parameters need to be considered. As a result, even with minimal reconfiguration, the output strategy can be significantly different.
OSA1
The oscillator submodules OSA1, OSA2, OSB1, and OSB2 are utilized to calculate oscillator values, display them on the chart, and evaluate them as independent signal generators. Meanwhile, OSA and OSB can combine the outputs of the previous four submodules to generate signals involving multiple oscillator lines. The submodule you will learn to configure in this section is highlighted in green in the subsequent diagram.
For a detailed explanation of the usage and configuration of each input parameter, please refer to the configuration article. All input parameters associated with the oscillator OSA1 submodules are grouped under the (OSA1) identifier and can be found in the table below.
Input variable within MetaTrader (Identifier in SET file) | Default value | Comment |
---|---|---|
> (OSA1) CONF, Signal in use (IN_enmOsa1SignalInUse) | OFF | The configuration article explains the meaning and usage of each input parameter. |
> (OSA1) CONF, Signal visualization (IN_enmOsa1SignalVisualization) | OFF | |
> (OSA1) CONF, Draw in chart (IN_enmOsa1DrawInChart) | ON | |
> (OSA1) CONF, Selection (IN_enmOsa1Selection) | MACD - Moving Averages Convergence-Divergence | |
> (OSA1) CONF, Symbol (IN_strOsa1Symbol) | CURRENT | |
> (OSA1) CONF, Exclusion (HH:MM:SS-HH:MM:SS) (IN_strOsa1Exclusion) | 00:00:00-00:00:00 | |
> (OSA1) CONF, Timeframe (IN_enmOsa1Timeframe) | CURRENT | |
> (OSA1) CONF, Series (IN_enmOsa1Series) | OPEN | |
> (OSA1) CONF, Shift (IN_nOsa1Shift) | 0 | |
> (OSA1) CONF, Line index (IN_nOsa1LineIndex) | 0 | |
> (OSA1) CONF, Parameter 1 (IN_dOsa1Parameter1) | 0.0 | |
> (OSA1) CONF, Parameter 2 (IN_dOsa1Parameter2) | 0.0 | |
> (OSA1) CONF, Parameter 3 (IN_dOsa1Parameter3) | 0.0 | |
> (OSA1) CONF, Parameter 4 (IN_dOsa1Parameter4) | 0.0 | |
> (OSA1) CONF, Parameter 5 (IN_dOsa1Parameter5) | 0.0 | |
> (OSA1) CONF, Parameter 6 (IN_dOsa1Parameter6) | 0.0 | |
> (OSA1) COND, Angle limit condition (IN_enmOsa1AngleCondition) | OFF | |
> (OSA1) COND, Angle limit 1 (IN_dOsa1AngleLimit1) | 0.0 | |
> (OSA1) COND, Angle limit 2 (IN_dOsa1AngleLimit2) | 0.0 | |
> (OSA1) COND, Value limit condition (IN_enmOsa1ValueCondition) | OFF | |
> (OSA1) COND, Value limit 1 (IN_dOsa1ValueLimit1) | 0.0 | |
> (OSA1) COND, Value limit 2 (IN_dOsa1ValueLimit2) | 0.0 |
This submodule is designed to generate trading signals using the MACD-MAIN oscillator line. As depicted in the chart below, the MACD-MAIN line is considered a positive trading signal only when its value is below zero, and the oscillator line is on an upward trend.
To accomplish this, the input parameters for conditions, namely > (OSA1) COND, Angle limit condition and > (OSA1) COND, Value limit condition, are set to the dropdown values of GREATER LIMIT 1 and SMALLER LIMIT 1, respectively.
A vertical green line is rendered whenever the signal is assessed as a positive trading signal for each bar in the current timeframe. This is due to the > (ORM) Operation being set to LONG SIGNAL ONLY, which implies that while signals are visually represented on the chart, no actual trades are executed.
To reproduce the chart from above, you can download and use the SET file package um_eab_coex_4_v_2_0.zip.
Given that the MACD oscillator is typically analyzed with its SIGNAL line, the OSA2 submodule will be employed to compute this line.
OSA2
Next, you will configure the submodule OSA2, highlighted in green in the following diagram.
For a comprehensive understanding of the usage and setup of each input parameter, please consult the configuration article. All input parameters related to the oscillator A2 submodules are categorized under the (OSA2) identifier and are listed in the table below.
Input variable within MetaTrader (Identifier in SET file) | Default value | Comment |
---|---|---|
> (OSA2) CONF, Signal in use (IN_enmOsa2SignalInUse) | OFF | The configuration article explains the meaning and usage of each input parameter. |
> (OSA2) CONF, Signal visualization (IN_enmOsa2SignalVisualization) | OFF | |
> (OSA2) CONF, Draw in chart (IN_enmOsa2DrawInChart) | ON | |
> (OSA2) CONF, Selection (IN_enmOsa2Selection) | MACD - Moving Averages Convergence-Divergence | |
> (OSA2) CONF, Symbol (IN_strOsa2Symbol) | CURRENT | |
> (OSA2) CONF, Exclusion (HH:MM:SS-HH:MM:SS) (IN_strOsa2Exclusion) | 00:00:00-00:00:00 | |
> (OSA2) CONF, Timeframe (IN_enmOsa2Timeframe) | CURRENT | |
> (OSA2) CONF, Series (IN_enmOsa2Series) | OPEN | |
> (OSA2) CONF, Shift (IN_nOsa2Shift) | 0 | |
> (OSA2) CONF, Line index (IN_nOsa2LineIndex) | 1 | |
> (OSA2) CONF, Parameter 1 (IN_dOsa2Parameter1) | 0.0 | |
> (OSA2) CONF, Parameter 2 (IN_dOsa2Parameter2) | 0.0 | |
> (OSA2) CONF, Parameter 3 (IN_dOsa2Parameter3) | 0.0 | |
> (OSA2) CONF, Parameter 4 (IN_dOsa2Parameter4) | 0.0 | |
> (OSA2) CONF, Parameter 5 (IN_dOsa2Parameter5) | 0.0 | |
> (OSA2) CONF, Parameter 6 (IN_dOsa2Parameter6) | 0.0 | |
> (OSA2) COND, Angle limit condition (IN_enmOsa2AngleCondition) | OFF | |
> (OSA2) COND, Angle limit 1 (IN_dOsa2AngleLimit1) | 0.0 | |
> (OSA2) COND, Angle limit 2 (IN_dOsa2AngleLimit2) | 0.0 | |
> (OSA2) COND, Value limit condition (IN_enmOsa2ValueCondition) | OFF | |
> (OSA2) COND, Value limit 1 (IN_dOsa2ValueLimit1) | 0.0 | |
> (OSA2) COND, Value limit 2 (IN_dOsa2ValueLimit2) | 0.0 |
As previously stated, the OSA2 oscillator submodule calculates and displays the MACD-SIGNAL line. Setting the input parameter > (OSA2) CONF, Line index to 1 is crucial. This instructs the oscillator submodule to use the signal line instead of the main line. Apart from this modification, the evaluation of angle and value remains the same as for the MACD-MAIN line. This leads to positive trading signals whenever the MACD-SIGNAL line is below zero but ascending. Please refer to the subsequent illustration to analyze the resulting output chart. The necessary input parameters to generate this chart can also be found there.
To reproduce the chart from above, you can download and use the SET file package um_eab_coex_6_v_2_0.zip.
As observed, the resulting trading signals, represented by vertical lines, occur at moments very similar to those for the OSA1 submodule.
OSA
Regarding the MACD indicator, it's standard practice to assess the SIGNAL and MAIN lines about one another. The OSA submodule is employed for this purpose, combining both oscillator lines configured earlier. As depicted in the block diagram below, this submodule takes the output values from OSA1 and OSA2 as inputs. It can then generate a signal based on combining these two values.
For a detailed understanding of the usage and configuration of each input parameter, please refer to the configuration article. All input parameters associated with the oscillator A submodules are grouped under the (OSA) identifier and found in the table below.
Input variable within MetaTrader (Identifier in SET file) | Default value | Comment |
---|---|---|
> (OSA) CONF, Signal in use (IN_enmOsaSignalInUse) | OFF | The configuration article explains the meaning and usage of each input parameter. |
> (OSA) CONF, Signal visualization (IN_enmOsaSignalVisualization) | OFF | |
> (OSA) COND, Relation 1 OSA1 to OSA2 (IN_enmOsaRelation1) | OFF | |
> (OSA) COND, Relation 2 OSA1 to OSA2 (IN_enmOsaRelation2) | OFF |
The goal is to limit positive signals to instances when the oscillator angle of the OSA1 submodule exceeds that of OSA2. By selecting ANGLE 1 GREATER ANGLE 2 as the necessary relational condition and enabling the OSA function block, the produced signal is restricted to these instances. This effectively reduces the number of signals and efficiently filters out incorrect signals.
To reproduce the chart from above, you can download and use the SET file package um_eab_coex_8_v_2_0.zip.
Given that initiating trades solely based on a MACD strategy is now considered outdated, it's essential to integrate the signal with a filtering process. To accomplish this, please proceed with configuring OSB1, OBS2, and OSB.
OSB1
Next, we'll establish a filter that identifies support and resistance levels. This will involve setting up the OSB1, OSB2, and OSB submodules, beginning with OSB1. The submodule you'll be guided to configure in this section is marked in green in the following diagram.
For a detailed understanding of the usage and configuration of each input parameter, please refer to the configuration article. All input parameters associated with the oscillator B1 submodules are grouped under the (OSB1) identifier and can be found in the table below.
Input variable within MetaTrader (Identifier in SET file) | Default value | Comment |
---|---|---|
> (OSB1) CONF, Signal in use (IN_enmOsb1SignalInUse) | OFF | The configuration article explains the meaning and usage of each input parameter. |
> (OSB1) CONF, Signal visualization (IN_enmOsb1SignalVisualization) | OFF | |
> (OSB1) CONF, Draw in chart (IN_enmOsb1DrawInChart) | ON | |
> (OSB1) CONF, Selection (IN_enmOsb1Selection) | ATR - Average True Range | |
> (OSB1) CONF, Symbol (IN_strOsb1Symbol) | CURRENT | |
> (OSB1) CONF, Exclusion (HH:MM:SS-HH:MM:SS) (IN_strOsb1Exclusion) | 00:00:00-00:00:00 | |
> (OSB1) CONF, Timeframe (IN_enmOsb1Timeframe) | CURRENT | |
> (OSB1) CONF, Series (IN_enmOsb1Series) | OPEN | |
> (OSB1) CONF, Shift (IN_nOsb1Shift) | 0 | |
> (OSB1) CONF, Line index (IN_nOsb1LineIndex) | 0 | |
> (OSB1) CONF, Parameter 1 (IN_dOsb1Parameter1) | 0.0 | |
> (OSB1) CONF, Parameter 2 (IN_dOsb1Parameter2) | 0.0 | |
> (OSB1) CONF, Parameter 3 (IN_dOsb1Parameter3) | 0.0 | |
> (OSB1) CONF, Parameter 4 (IN_dOsb1Parameter4) | 0.0 | |
> (OSB1) CONF, Parameter 5 (IN_dOsb1Parameter5) | 0.0 | |
> (OSB1) CONF, Parameter 6 (IN_dOsb1Parameter6) | 0.0 | |
> (OSB1) COND, Angle limit condition (IN_enmOsb1AngleCondition) | OFF | |
> (OSB1) COND, Angle limit 1 (IN_dOsb1AngleLimit1) | 0.0 | |
> (OSB1) COND, Angle limit 2 (IN_dOsb1AngleLimit2) | 0.0 | |
> (OSB1) COND, Value limit condition (IN_enmOsb1ValueCondition) | OFF | |
> (OSB1) COND, Value limit 1 (IN_dOsb1ValueLimit1) | 0.0 | |
> (OSB1) COND, Value limit 2 (IN_dOsb1ValueLimit2) | 0.0 |
The price profile oscillator calculates two value lines, accessible via line indices 0 and 1. Selecting line index 1 displays the consolidation line in the chart window. Typically, the price profile oscillator generates an in-chart histogram that shows the frequency of each price within the observed period, which in this case is set to 6000 bars using the input parameter > (OSB1) CONF, Parameter 1.
The consolidation line represents the value of the current histogram block where the price is moving. This implies that the larger the oscillator value, the more frequently a price has occurred. Conversely, a smaller value indicates a less frequent price appearance.
For accurate signals, the submodule should only generate signals when the current price is more likely within a movement phase rather than a consolidation phase. To achieve this, the input parameter > (OSB1) COND, Value limit condition is set to SMALLER LIMIT 1, with the limit configured at 40. As a result, a positive trading signal is only evaluated when the indicator value is less than 40.
To reproduce the chart from above, you can download and use the SET file package um_eab_coex_10_v_2_0.zip.
As observed, the resulting trading signals occur too frequently, indicating the need for filtering. For this purpose, the second line calculated by the price profile oscillator will be utilized.
OSB2
The last oscillator line to be configured for this trading strategy is computed by the OSB2 submodule. The submodule that will be configured in this section is highlighted in green in the diagram that follows.
For an in-depth understanding of the usage and setup of each input parameter, please consult the configuration article. All input parameters related to the oscillator B2 submodules are categorized under the (OSB2) identifier and are listed in the table below.
Input variable within MetaTrader (Identifier in SET file) | Default value | Comment |
---|---|---|
> (OSB2) CONF, Signal in use (IN_enmOsb2SignalInUse) | OFF | The configuration article explains the meaning and usage of each input parameter. |
> (OSB2) CONF, Signal visualization (IN_enmOsb2SignalVisualization) | OFF | |
> (OSB2) CONF, Draw in chart (IN_enmOsb2DrawInChart) | ON | |
> (OSB2) CONF, Selection (IN_enmOsb2Selection) | RSI - Relative Strength Index | |
> (OSB2) CONF, Symbol (IN_strOsb2Symbol) | CURRENT | |
> (OSB2) CONF, Exclusion (HH:MM:SS-HH:MM:SS) (IN_strOsb2Exclusion) | 00:00:00-00:00:00 | |
> (OSB2) CONF, Timeframe (IN_enmOsb2Timeframe) | CURRENT | |
> (OSB2) CONF, Series (IN_enmOsb2Series) | OPEN | |
> (OSB2) CONF, Shift (IN_nOsb2Shift) | 0 | |
> (OSB2) CONF, Line index (IN_nOsb2LineIndex) | 0 | |
> (OSB2) CONF, Parameter 1 (IN_dOsb2Parameter1) | 0.0 | |
> (OSB2) CONF, Parameter 2 (IN_dOsb2Parameter2) | 0.0 | |
> (OSB2) CONF, Parameter 3 (IN_dOsb2Parameter3) | 0.0 | |
> (OSB2) CONF, Parameter 4 (IN_dOsb2Parameter4) | 0.0 | |
> (OSB2) CONF, Parameter 5 (IN_dOsb2Parameter5) | 0.0 | |
> (OSB2) CONF, Parameter 6 (IN_dOsb2Parameter6) | 0.0 | |
> (OSB2) COND, Angle limit condition (IN_enmOsb2AngleCondition) | OFF | |
> (OSB2) COND, Angle limit 1 (IN_dOsb2AngleLimit1) | 0.0 | |
> (OSB2) COND, Angle limit 2 (IN_dOsb2AngleLimit2) | 0.0 | |
> (OSB2) COND, Value limit condition (IN_enmOsb2ValueCondition) | OFF | |
> (OSB2) COND, Value limit 1 (IN_dOsb2ValueLimit1) | 0.0 | |
> (OSB2) COND, Value limit 2 (IN_dOsb2ValueLimit2) | 0.0 |
This oscillator submodule employs the same price profile indicator as previously set up. Unlike OSB1, the line index here is set to 1, resulting in the plotting of the position line. The position line can also range between 0 and 100. A value near zero indicates that the price is close to the lower range of the observed 6000-bar period, while a value near 100 suggests that the price is at the upper range.
To reproduce the chart from above, you can download and use the SET file package um_eab_coex_12_v_2_0.zip.
Considering that the signal is designed for a long trading strategy, excluding periods when the price is too close to a resistance or support level makes sense. The input parameter > (OSB1) COND, Value limit condition is set to BETWEEN LIMIT 12 to achieve this. Limit 1 is configured at 20 and limit 2 at 80, effectively excluding values outside this range.
OSB
As previously stated, it's necessary to combine OSB1 and OSB2 to restrict the number of positive signals to a manageable level. For this purpose, we'll use the INB submodule. The diagram below shows that this function block receives the oscillator values and angle information as input.
For an in-depth understanding of the usage and setup of each input parameter, please consult the configuration article. All input parameters related to the oscillator B submodules are categorized under the (OSB) identifier and are listed in the table below.
Input variable within MetaTrader (Identifier in SET file) | Default value | Comment |
---|---|---|
> (OSB) CONF, Signal in use (IN_enmOsbSignalInUse) | OFF | The configuration article explains the meaning and usage of each input parameter. |
> (OSB) CONF, Signal visualization (IN_enmOsbSignalVisualization) | OFF | |
> (OSB) COND, Relation 1 OSB1 to OSB2 (IN_enmOsbRelation1) | OFF | |
> (OSB) COND, Relation 2 OSB1 to OSB2 (IN_enmOsbRelation2) | OFF |
The combined signal, derived from the oscillator values OSB1 and OSB2, is illustrated in the example chart below. The number of trading signals is significantly reduced by using the relation VALUE 1 SMALLER VALUE 2 as input parameters for > (OSB) COND, Relation 1 OSB1 to OSB2.
To reproduce the chart from above, you can download and use the SET file package um_eab_coex_14_v_2_0.zip.
The final step involves combining all oscillator submodules.
Final signal
Let's combine the configured oscillators from above to create a unified trading signal. To do this, please enable the Signal in use input option for OSA1, OSA2, OSA, OSB1, OSB2, and OSB. A complete list of the modified input parameters and the resulting chart output can be found below.
To reproduce the chart from above, you can download and use the SET file package um_eab_coex_15_v_2_0.zip.
As observed, the final signal is less frequent and indicates short-term upward movement, presenting a good opportunity for long trades. However, please note that this is merely an example and does not purport to be a fully functional and profitable trading strategy. Nonetheless, it can be a starting point for building a trading module based on the oscillator functional block.
When executing the trading strategy with the Custom Expert Advisor, you may prefer to maintain a clean chart window without numerous oscillator lines. To achieve this, you can turn off the drawing of the oscillator lines using the input parameters that contain the text Draw in chart. This will result in a clean chart displaying the trading signals as vertical green lines.
To reproduce the chart from above, you can download and use the SET file package um_eab_coex_16_v_2_0.zip.
These vertical green lines are a result of the input parameters > (ORM) Operation and > (MIS) General signal visualization. Please adjust these input parameters accordingly to enable the trading module to open long trades whenever a signal is given. You will then notice that long trades are initiated instead of indicating the trading signals. This article does not focus on configuring the stop loss and take profit levels. For information on that, please refer to the relevant user manual article.
To reproduce the chart from above, you can download and use the SET file package um_eab_coex_17_v_2_0.zip.
Although you have configured the final signal with the assumption of executing long trades, it is also straightforward to test the same signal with short trades. Change the input parameter > (ORM) Operation from LONG to SHORT to do this.
To reproduce the chart from above, you can download and use the SET file package um_eab_coex_18_v_2_0.zip.