Defining a global trend
Use_Trend — includes a trend indicator.
Use_Trend_Roll — the operating mode of the trend indicator. The selection of the mode determines the purpose of the parameters TInd0Param… .
| Mode | Description | Parameters |
|---|---|---|
| qUseTrendCand | Working on a price rollback (mode 1) | TInd0Param0 — period; TInd0Param4 - level |
| qUseTrendHL | Working on a price rollback (mode 2) | TInd0Param0 — period; TInd0Param4 - level |
| qUseTrendMa | Working according to the trend (mode 1) | TInd0Param3 — period |
| qUseTrendMaRoll | Working on a price rollback (mode 3) | TInd0Param4 - level |
| qUseTrendMaRsi | Working on a price rollback (mode 4) | TInd0Param0 — flat period; TInd0Param1 — lower level of the flat; TInd0Param2 — upper level of the flat; TInd0Param4 — trend level |
| qUseTrendInside | Working with the trend (mode 2) | TInd0Param0 — flat period; TInd0Param1 — lower level of the flat; TInd0Param2 — upper level of the flat; TInd0Param4 — trend level |
| qUseRoll | Working in flat (mode 1) | TInd0Param0 — flat period; TInd0Param1 — lower level of the flat; TInd0Param2 — upper level of the flat |
| qUseLevel | Work in flat (mode 2) | TInd0Param0 — flat period; TInd0Param1 — lower level of the flat; TInd0Param2 — upper level of the flat |
Default parameters (Ind_0_Param_…):
| Parameter | Purpose |
|---|---|
| Ind_0_Param_0 | RSI period |
| Ind_0_Param_1 | RSI oversold zone |
| Ind_0_Param_2 | RSI overbought zone |
| Ind_0_Param_3 | MA indicator period |
| Ind_0_Param_4 | Deviation of MA from its average price |
| Ind_0_Param_5 | Additional parameter: adds or subtracts start/stop values for Auto_Set_Param_4 during optimization. For subtraction, use a minus value. |
Candle_Shift — shift of bars for trend calculation.
Auto_Set_Param_0 — automatic setting of optimization values (start, step, stop) for the parameter Ind_0_Param_0 . Works only when enabled. Auto_Set_Default .
Auto_Set_Param_4 — the same for the parameter Ind_0_Param_4 .
Determining price strength and speed
Speed — includes a block for determining the speed and strength of price movement.
Bar_Size_No_Speed — determining strength without speed. When disabled, the EA only works on every tick (recommended) or by control points (rough method). Speed cannot be determined based on opening prices.
Speed_Reverse — reverse signal for price reversal (general).
Roll_Back — a reverse signal for a price reversal (separate, without a reversal of auxiliary indicators).
Pips — the power of price.
Time — price speed.
Speed_Indicators — auxiliary indicators for determining price direction. The parameters' assignment depends on the selected mode.
| Mode | Description | Parameters |
|---|---|---|
| Off | Not used | — |
| iMa | Mode 1 | Ind_0_Param_4 — period; Ind_0_Param_5 - level |
| iBand | Mode 2 | Ind_0_Param_4 — period; Ind_0_Param_5 — channel width |
| Envelopes | Mode 3 | Ind_0_Param_4 — period; Ind_0_Param_5 — channel width |
| Fractals | Mode 4 | — |
| iRsi | Mode 5 | Ind_0_Param_4 — period; Ind_0_Param_6 — the upper boundary of the channel; Ind_0_Param_5 — the lower boundary of the channel |
| iAtr | Mode 6 | Ind_0_Param_4 — period; Ind_0_Param_5 — minimum value; Ind_0_Param_6 — maximum value |
Additional parameters: hInd_0_Param_4 , hInd_0_Param_5 , hInd_0_Param_6 , hInd_0_Param_7 .
Speed_Shift — the bar shift used to determine price strength. When trading only at opening prices, it should be greater than 0.
Set_Pips_Range — automatic optimization setup (start, step, stop) for Pips. Works only when enabled. Auto_Set_Default .
Set_Time_Range - the same for Time .
Opening Price Trading and Basic Settings
| Parameter | Description |
|---|---|
| Open_Bar | Opening positions exclusively at opening prices |
| Indicator_Period | Operating period of the indicator block |
| Candle_Direction | Taking into account the direction of the last two bars |
| Reverse | Feedback signal from the main indicator unit |
Main indicator block
Strategies (Open) — strategies for opening positions
-1: iCustom — connection of a user indicator unit.
To connect your own algorithm:
- Install a custom indicator in the terminal iEmperor.ex5 (not to be confused with the library iEmperor.ex5 ). Download: When you try to open the file, the indicator will be installed in the last active MT5 terminal.
- Write an algorithm for the indicator block in the library code iEmperor.mq5 . In MetaEditor, select the "Library" type.
- You can change everything, except : library name ( iEmperor ), function name ( MyCalculator ), number of input parameters ( Ind_0_Param_0 … Ind_0_Param_15 — even if not used) and output values: return(1) - purchase, return(-1) - sale, return(0) — pause.
- After compilation in MetaEditor library iEmperor.ex5 will be saved in the terminal.
Custom Block Management:
- Reverse - signal reversal.
- Ind_0_Param_0 — selection of calculation method.
- Ind_0_Param_1 … Ind_0_Param_15 — settings corresponding to the selected calculation method (from 1 to 15 parameters).
0: iNo — do not use.
Built-in opening strategies (for optimization it is enough to enable Auto_Set_Default — start, step and stop are set automatically):
| No. | Indicators | No. | Indicators | No. | Indicators |
|---|---|---|---|---|---|
| 1 | iRSI | 2 | iRSI, iMA | 3 | iRSI, iATR |
| 4 | iStochastic, iMA | 5 | iTrend, iATR | 6 | iMA, iCCI, iSAR |
| 7 | iBands, iMA | 8 | iBrakema | 9 | iMACD |
| 10 | iWPR, iEnvelopes | 11 | iADX | 12 | iFractal |
| 13 | iZigZag | 14 | iZigZag | 15 | MA, Band, Env, Frac, RSI, ATR |
| 16 | iOpen, iClose | 17 | iZigZag | 18 | iMA |
| 19 | iAlligator, iFractal | 20 | iMA | 21 | iTrend |
| 22 | iBands | 23 | iCCI, iMA, iLevels | 24 | iForce |
| 25 | iMA | 26 | iStochastic | 27 | iMA, iCHO |
| 28 | iATR, iBands | 29 | iDeM | 30 | iATR, iSTO |
| 31 | iMA, iAO, iTriX | 32 | iCCI, iMA, iSAR | 33 | iMACD |
| 34 | iAlligator | 35 | iAC, iAlligator | 36 | iSAR, iOsMA |
| 37 | iEhlers_CG | 38 | iMACD | 39 | iFisher |
| 40 | iPercent | 41 | iCCI, iMA | 42 | iMA, iMACD |
| 43 | iMA, iZigZag | 44 | iHigh, iOpen | 45 | iMA, iAO |
| 46 | iMACD | 47 | iMA, iRVI | 48 | iADXWilder |
| 49 | iMA, iCCI, iSD | 50 | iBands, iAC | 51 | iADX |
| 52 | iRVI, iADX | 53 | iStochastic | 54 | iMomentum, iDeMarker |
| 55 | iMFI | 56 | iVolumes, iADX, iMA | 57 | iAC, iCCI |
| 58 | iMA, iCCI, iStdDev | 59 | iMomentum, iEnvelopes | 60 | iRSI |
| 61 | iRVI | 62 | iMFI, iStochastic, iADX | 63 | iAO, iAC |
| 64 | iBands, iMA, iMA | 65 | iStochastic | 66 | iStochastic, iADX, iAC |
| 67 | iStochastic, iMA, iMA | 68 | iCCI | 69 | iBands |
| 70 | iAlligator, iRSI | 71 | iRVI, iStochastic | 72 | iStochastic, iVolumes, iRSI |
| 73 | iWPR, iEnvelopes | 74 | iADX | 75 | iCCI, iVolumes |
| 76 | iMomentum, iStochastic, iRVI | 77 | iMFI, iMA, iMA |
Strategies (Close) — strategies for closing positions
-2: Return_Signal — closing based on a feedback signal from the indicator block operating for opening.
-1: iCustom — closing by a signal from the user indicator unit. The procedure is the same as for opening. Setting:
- Ind_1_Param_1 — selection of calculation method
- Ind_1_Param_2 … Ind_1_Param_15 — parameters of the selected method
0: iNo — do not use.
Built-in closing strategies:
| No. | Indicators | No. | Indicators | No. | Indicators |
|---|---|---|---|---|---|
| 1 | iCCI | 9 | iHigh, iLow | 10 | iAlligator |
| 11 | iBands | 12 | iMA | 21 | iTrend |
| 50 | iAlligator | 51 | iWPR | 52 | iDeMarker |
| 53 | iBands | 54 | iRSI | 55 | iBands |
| 56 | iCCI | 57 | iBands | 58 | iADX |
| 59 | iRSI | 60 | iEnvelopes | 61 | iWPR |
| 62 | iBands | 63 | iBands | 64 | iEnvelopes |
| 65 | iAlligator | 66 | iEnvelopes | 67 | iBands |
| 68 | iAlligator | 69 | iWPR | 70 | iEnvelopes |
| 71 | iAlligator | 72 | iBands | 73 | iAlligator |
| 74 | iBands | 75 | iADX | 76 | iEnvelopes |
| 77 | iEnvelopes |
Speeding up the Advisor's work
| Parameter | Description |
|---|---|
| Open_Continue | If enabled, all operations (except trailing stop and modification of pending orders) are performed only upon a signal main indicator block. When turned on Pos_All_Continue - for all positions, otherwise only for the first ones |
| Trend_Continue | The same on signal trendy indicator block |
| Speed_Continue | The same on signal power indicator block |
| Pos_All_Continue | If enabled, all positions and orders (including averaging ones) are opened strictly based on signals from indicator blocks. If disabled, only the first positions in a series are opened based on signals, with the rest at a specified distance. |
Automatic setting of parameter values for optimization
| Parameter | Description |
|---|---|
| Auto_Set_Default | Master switch for automatic optimization variable settings for all parameters. When disabled, manual mode is activated. |
| Auto_Set_Time | Automatic installation for temporary sessions |
| Auto_Set_Type | Auto-installation for pending orders |
| Auto_Set_Fractal | Automatic installation for fractals |
| Auto_Set_ZigZag | Automatic installation for the ZigZag indicator |
| Auto_Set_Speed | Automatic installation for the power unit |
| Auto_Set_Expiration | Automatic setting for expiration (lifetime) of positions and orders |
Automatic optimization
MultiLevelRecording (MLR) — the number of folders with settings files. If 0 — settings are not saved. During optimization, the advisor analyzes the results of each run and saves the best ones in separate files. Increasing the MLR value allows you to save multiple combinations of settings for diversification: while a loss is possible on one account, a profit is possible on another.
- Primary folder number - parameter Folder_Number .
- Subfolders are numbered starting from Magic_Number , each subsequent one — Magic_Number + serial number .
Forward_Risk — forward testing risk. Allows for an overestimation of the deposit load during forward testing.
- Fixed lot: Forward_Risk × Lot . Example: Lot = 0.01 , Forward_Risk = 10 → optimization from 0.01, forward from 0.1.
- Automatic calculation: Forward_Risk / Risk . Example: Risk = 100 with a discretion of 0.01, Forward_Risk = 10 → optimization 0.01 lot per 100 units, forward - 0.1 lot per 100 units.
- If 0 — not used.
Pause_Pass — the number of files to skip after saving the next one, to diversify trading. If 0 — not used.
Auto_Start_Time — the total number of bars to optimize. Automatically determines the optimization start date based on the chart period. Example: 18,000 bars on H1 — approximately 2 years. For shorter periods, the optimization time is reduced proportionally.
- Disadvantage: When optimizing based on opening prices, an extra section may be wasted if the strategy tester is set to a longer period than the EA requires. This does not affect the optimization quality.
Start_Time — optimization start time (set manually), if Auto_Start_Time = 0 .
Total_Pass — defines the optimization method:
| Meaning | Mode | Description |
|---|---|---|
| 0 | Measured | The robot selects settings for each pair in turn until all combinations are exhausted. Plus: equal number of files in all folders. Minus: may get stuck on one pair without selecting the settings to suit the criteria |
| > 0 | Unmeasured | The robot selects settings for each pair in a limited number of passes Total_Pass , then switches to the next one and so on in a circle. Plus: no looping. Minus: The folders are filled unevenly (the first one has the most files, the subsequent ones have less) |
Use_Forward_Tester — If enabled, settings are saved only during automatic forward testing. The results are ignored during optimization.
Symbol_Total — the total number of characters to optimize. Characters are read in order.
Switch_Symbol — choice of currency pair:
- -2 - all pairs from the list
- -1 - only the current pair of strategy testers
- 0 and more - a specific pair from the list (0 - first, 1 - second, etc.)
Manual_Control — If enabled, the advisor selects settings only during testing (not optimization). Only those settings you manually select after optimization is complete are reviewed.
Symbol_Filter — if enabled, the robot downloads settings only for pairs from the list. The list is delimited by / . The default setting is 28 currency pairs. Up to 200 instruments are allowed.
The more pairs used, the higher the load on the terminal and server. When the server is overloaded, the advisors are forcibly unloaded, but when they return to the charts, they reliably find their positions.
Auto_Magic_Number - automatic change of identifier Magic_Number (default is the starting number of subfolders in Folder_Number ). Necessary for automated testing after optimization.
Detailed description of the parameters
- https://www.mql5.com/en/blogs/post/775377 (part 1)
- https://www.mql5.com/en/blogs/post/775378 (part 2)
- https://www.mql5.com/en/blogs/post/775379 (part 3)
Emperor Expert Advisor page in MQL5 Market
- Emperor — MQL5 Market: https://www.mql5.com/en/market/product/59948
![[Action Required]: Manual EA Pause Recommended [Action Required]: Manual EA Pause Recommended](https://c.mql5.com/6/1027/splash-preview-775266.png)

