1. Introduction
This is the documentation for Sapphire Strat Maker and Sapphire Strat Maker Alt (Free) expert advisor - an EA which allows you to create your own strategy without coding. This is the beauty of this Expert Advisor: create your own strategies - be creative - and don't be locked to a single strategy anymore. Optimize the parameters you want to find the best sets and you're ready to go!
Current preset strategies (updating constantly):
- GBPUSD - Timeframe: H1 - Bollinger Bands crossover by MA - tested from 2022.03.01 to 2024.03.14 - both versions of the EA;
- EURUSD - Timeframe: H4 - Midpoint Bands + MA + ADX + ATR - tested from mar/2018 to mar/2024 - available only for Sapphire Strat Maker;
- GBPUSD - Timeframe: M5 - Reversal on Bollinger Bands + Moving Average Signal - tested from 2023.03.01 to mar/2024 - both versions of the EA;
Feel free to contact me if you have any question about the documentation or need help to create a strategy.
2. Blog posts
Documentation - Indicators information
Documentation - ENUMs information
Part I - An easy way to create strategies
Part II - How to create your own strategy
Part III - Working with indicators buffers
Part IV - Insights on strategies optimization and efficiency
3. Documentation
Group | Parameter name | Description |
---|---|---|
[0] Expert Advisor | Magic | Defines the expert advisor magic number, which uniquely identifies deals/trades executed by this EA. |
[0] Expert Advisor | Trading symbol | Symbol in which trades will be executed. If no value is set, the defined strategy tester or chart symbol is defined. This is useful when operating on non-tradeable futures historical series or if your strategy demands acquiring data from one symbol (defined in the ST or in the chart), but trades on another one. |
[0] Expert Advisor | Get underlying symbol | Gets the underlying symbol for the brazilian futures series (WIN and WDO). Only works in brazilian market. Should be set to false in ANY other case to avoid errors. |
[0] Expert Advisor | Note N | Set observations to this specific EA. This is not used for the stategy and has no effect in the EA whatsoever. |
[1] Trading Settings | Trading mode | Defines if the EA will have only one position at time or if it is allowed to open multiple positions whenever a new buy/sell signal is received. |
[1] Trading Settings | Indicators timeframe | Defines the global timeframe for indicators. This can be overriden in the specific indicator timeframe settings. |
[1] Trading Settings | Use start time | Defines if Start time condition is allowed to be checked. |
[1] Trading Settings | Use end time | Defines if End time condition is allowed to be checked. |
[1] Trading Settings | Use close time | Defines if Close time condition is allowed to be checked. |
[1] Trading Settings | Start time | Sets the start time so the EA can operate. This does include the time set (if you set it to 09h00 and you're operating on the M1 timeframe, the first candle evaluated will be the 09h00 candle). |
[1] Trading Settings | End time | Sets the end time so the EA cannot open any new positions. This does not include the time set (if you set it to 15h00 and you're operating on the M1 timeframe, the EA will still be able to open new positions at 15h00; not anymore at 15h01). |
[1] Trading Settings | Close time | Sets the close time so the EA cannot open any new positions and closes all open positions . This does not include the time set (if you set it to 17h00 and you're operating on the M1 timeframe, the EA will still be able to open new positions until 17h00 if the end time is not set otherwise ; not anymore at 17h01, time at which all positions will also be closed). |
[1] Trading Settings | Ignore first day bar | The EA will not evaluate the last candle of the day before. This means that the first buy/sell condition will be evaluated after the first candle of the day is closed. |
[1] Trading Settings | Indicator buffer update bars | Defines how much data (in bars) shall be retrieved from the indicators. The default value is pretty much enough for most cases, but if you need to retrieve values older than the last 8 bars (including the current opening one), increase this value. Setting a value lower than the required by the conditions you specify may return an Array out of range error. |
[1] Trading Settings | Show indicators on live chart | If true, loads the indicators on live chart. |
[1] Trading Settings | Show indicators while testing | If true, shows indicators on the strategy tester visual mode. |
[1] Trading Settings | Allow to modify existing trades | If Enable , allows the EA to modify TP and SL levels. This is valid for any modification of take profit or stop loss , including trailing stops (not implemented) or breakeven (later section). If Disabled, even if any modification option is set, the EA will not modify the defined TP or SL when the position was opened. |
[1] Trading Settings | Reference price for TP/SL | Defines the reference price to define take profit/stop loss in the Fixed mode. This is important to assure that strategy tester results are closer to the expected in real trading. - TP/SL from current open states that take profit/stop loss is calculated from the current open price (default; this ensures the better results, because the position is always executed at the first tick of a new candle, i.e., the current open price); - TP/SL from last close states that take profit/stop loss is calculated from the last close price (may be misleading, since the current open may not be equal to the last close in certain cases, specially in swing trading); - TP/SL from bid/ask states that take profit/stop loss is calculated from the bid/ask (this would be the best option; however, bid/ask may differ a lot in strategy testing. Also, in real trading, this can put your tp/sl levels way above/below the desired level in a way that the order would be executed in the backtesting, but not in a real trading). |
[2] Tester Settings | Test type | If the strategy tester optimization criteria is Custom Max , it returns the defined value in this variable. Always prefer Custom Max and define the optimization method this way, so the optimizing tests are faster if you define any of the subsequent parameters. |
[2] Tester Settings | Allow functions on mode | Allows Max Drawdown , Max trades , Max trade by trade drawdown and Max absolute balance loss on the specified testing mode. |
[2] Tester Settings | Max drawdown (%) | Defines the maximum drawdown. If the EA detects a bigger drawdown, it immediately stops testing, significantly increasing the test speed. |
[2] Tester Settings | Max trades | Defines the maximum number of trades. If the EA detects more trades, it immediately stops testing, significantly increasing the test speed. |
[2] Tester Settings | Max trade by trade drawdown | Defines the maximum trade by trade drawdown (i.e., consecutive losses drawdown). If the EA detects a bigger trade by trade drawdown, it immediately stops testing, significantly increasing the test speed. |
[2] Tester Settings | Max absolute balance loss | Defines the maximum balance loss. If the EA detects an absolute drawdown more than the specified value, it immediately stops testing, significantly increasing the test speed. |
[2] Tester Settings | Withdrawal condition | If the user wants to simulate withdrawals while testing, set this condition to any value except None . - Withdraw Daily, Weekly and Monthly makes withdrawals every defined period; - Withdraw when balance is bigger/lower than makes withdrawals if balance is bigger/lower than the value in the variable Reference money to withdraw . |
[2] Tester Settings | Reference money to withdraw | Defines the reference money to start withdrawing (example: if Withdrawal condition is Withdraw when balance is bigger than and Reference money to withdraw is 10.000, withdrawals will be made once a day, in the first candle, before the first trade, whenever the balance is bigger than 10.000). |
[2] Tester Settings | Withdrawal amount | Defines the amount to withdraw. |
[2] Tester Settings | Deposit condition | If the user wants to simulate deposits while testing, set this condition to any value except None. - Deposit Daily , Weekly and Monthly makes deposits every defined period; - Deposit when balance is bigger/lower than makes deposits if balance is bigger/lower than the value in the variable Reference money to deposit . |
[2] Tester Settings | Reference money to deposit | Defines the reference money to start deposition (example: if Deposit condition is Deposit when balance is lower than and Reference money to deposit is 10.000, deposits will be made once a day, in the first candle, before the first trade, whenever the balance is lower than 10.000). |
[2] Tester Settings | Deposit amount | Defines the amount to deposit. |
[3] Indicators | [3.N] Indicator | Desired indicator from the list. The N indicates the index of the indicator which will be used in the signals/profit levels/trailing stops (0 = index 0, 1 = index 1, etc., up to 9 = index 9). |
[3] Indicators | [3.N] Path to custom indicator | Sets the path to the custom indicator (it must be at MQL5\Indicators ). |
[3] Indicators | [3.N] Indicator timeframe | Timeframe at which the indicator will be launched. If this value is other than current, it overrides in the global Indicators timeframe input defined in the [1] Trading Settings section. |
[3] Indicators | [3.N] Param 1 | 1st indicator parameter. If it's a custom indicator, this parameter MUST be the amount of buffers in the indicator, and the 2nd parameter is actually the 1st parameter of the indicator and so on. |
[3] Indicators | [3.N] Param 2 | 2nd parameter. |
[3] Indicators | [3.N] Param 3 | 3rd parameter. |
[3] Indicators | [3.N] Param 4 | 4th parameter. |
[3] Indicators | [3.N] Param 5 | 5th parameter. |
[3] Indicators | [3.N] Param 6 | 6th parameter. |
[3] Indicators | [3.N] Param 7 | 7th parameter. |
[3] Indicators | [3.N] Param 8 | 8th parameter. |
[3] Indicators | [3.N] Param 9 | 9th parameter. |
[4] Entry signals | Allow buy signals | Allow to open buy positions. If false , no buy positions will be opened. |
[4] Entry signals | Allow sell signals | Allow open sell positions. If false , no sell positions will be opened. |
[4] Entry signals | Buy signals filling mode | Filling mode for buy signals. If Fill all conditions , all defined conditions must be simultaneously met to open a new buy position; If Fill any conditions , any of the defined conditios must be met to open a new buy position, regardless of the others. |
[4] Entry signals | Sell signals filling mode | Read the documentation for Buy signals filling mode . |
[4] Entry signals | Common signals filling mode | Specifically for this parameter, if there are no common signals, this should be set to Fill any condition, otherwise, no position will be opened. Read the documentation for Buy signals filling mode . |
[4.1] Buy signals [4.2] Sell signals [4.3] Common signals | [X.Y] Series to compare | Indicates the first series used for comparation. The X indicates the number of the signal (since there are the possibility to set 5 signals, it ranges from 1 to 5), mainly used for organization. The Y means the value to be compared; there are 2 values per signal, so it ranges from 1 to 2, and value 1 will be compared against value 2. If it results to true, and all other conditions are fullfiled according to the set filling mode, a buy signal is returned. The series are defined as followed: - Open, High, Low and Close return the defined series; - Amplitude returns the amplitude (distance between high and low) of the candle; - Amplitude (open-close) returns the open-close distance (candle body); - Fixed returns no series, but a pre-defined user input value set in the input Bar shift/Fixed value; - Indicator returns an indicator buffer, whose parameteres are defined in the subsequent inputs; - Tick volume returns the tick volume series; - Real volume returns the real volume series. |
[4.1] Buy signals [4.2] Sell signals [4.3] Common signals | [X.Y] Math operation on series | Apply a mathematical operation to the series value with the value set in the variable Value . It can be one of the following: - None : no operation is applied; - Add: adds the series value to the value defined in Value ; - Sub: subtract the series value by the value defined in Value ; - Mult: multiply the series value by the value defined in Value ; - Div: divide the series value by the value defined in Value ; - Highest: gets the highest value. The start value is defined in the parameter Bar Shift/Fixed value , while the count to search the highest value is defined by the variable Value ( example: if Bar Shift/Fixed value is 1 and Value is 7, it will search for the highest value, starting from the bar of index 1 to the bar of index 7, i.e., 7 bars back). If the series is specifically defined as Indicator , Bar Shift/Fixed value shall not be higher than the Indicator buffer update bars input, nor the sum of Bar Shift/Fixed value and Value should be bigger than Indicator buffer update bars input, otherwise, an Array out of range error may raise. - Lowest: gets the lowest value. Behaves exactly as Highest parameter. - Average : gets the simple average of the series. Behaves exactly as Highest and Lowest . |
[4.1] Buy signals [4.2] Sell signals [4.3] Common signals | [X.Y] Value | Value to be applied by a mathematical operation, according to the desired input Math operation to series . |
[4.1] Buy signals [4.2] Sell signals [4.3] Common signals | [X.Y] Indicator index | If Series to compare is set to Indicator, sets the indicator index from which to retrieve data (read [3.N] Indicator input for more info.). Has no effect otherwise. |
[4.1] Buy signals [4.2] Sell signals [4.3] Common signals | [X.Y] Indicator buffer | If Series to compare is set to Indicator, retrieves data from the buffer indicated by this input. Has no effect otherwise. If Indicator buffer is set to a value bigger than the amount of buffers of the selected indicator, it may result in an Array out of range error. |
[4.1] Buy signals [4.2] Sell signals [4.3] Common signals | [X.Y] Bar shift/fixed value | The bar to retrieve data, ranging from 0 to Indicator buffer update bars if Series to compare is set to Indicator. If Series to compare it is set to anything else, other than Indicator or Fixed, it ranges from 0 to the maximum amount of bars otherwise. If Series to compare is set to Fixed, this input represents the fixed value. |
[4.1] Buy signals [4.2] Sell signals [4.3] Common signals | [X.Y] Comparison method | Defines the comparison method to evaluate the condition. Currently these are the comparison methods available: - Crossing upwards/downwards: this method checks if the series defined in X.1 is crossing upwards/downwards the series defined in X.2. A crossing upwards happens when the bar 1 of the series in X.1 is above the bar 1 of the series defined in X.2 and the bar 2 of the series X.1 is below the bar 2 of the series defined in X.2. Since this method already defines the bars, the parameter Bar shift/fixed value is ignored. Only the Indicator index and Indicator buffer inputs are required. - Upwards/downwards: checks if the series defined in X.1 are going up or down. In this case, series defined in X.2 are ignored. A series is going upwards if the bar 1 is above bar 2; it is going downwards if the bar 1 is below bar 2. Since this method already defines the bars, the parameter Bar shift/fixed value is ignored. Only the Indicator index and Indicator buffer inputs are required. - Reversal up/down: checks if the series were going up and reversed down or the inverse. A series is reversing up when the bar 2 was below the bar 3, but the bar 1 is above bar 2; it is reversing down when bar 2 was above the bar 3, but the bar 1 is below bar 2. Since this method already defines the bars, the parameter Bar shift/fixed value is ignored. Only the Indicator index and Indicator buffer inputs are required. - > (greater), < (lower), >= (greater/equal), <= (lower/equal), == (equal), != (diff): these are all self-explanatory. If X.1 compares true against X.2, it may result in a buy signal. Here all parameters of the signal shall be defined (Indicator index, indicator buffer and Bar shift/fixed value). Note that Indicator index and Indicator buffer may be 0. Bar shift/fixed value can be 0 aswell, but only for a matter of compatibility with a future OnTick mode instead of only a NewBar based trading bot. It is highly recommendable to use bars starting from index 1. |
[5.1] Order Type | ----------------- | Order type is not implemented yet and only orders at market are allowed. Changing input parameters shall have no effect. |
[5.2] Take Profit [5.3] Stop loss | Update take profit levels Update stop loss levels | If true , it allows the recalculation of take profit levels. If the next Take profit series on both buy/sell is set to Fixed , this has no effect. Otherwise, the take profit level will be updated to the new data of the selected series data. Example: suppose you the order is opened with take profit on a moving average. Every candle, if this input is true, the take profit will be set to the new moving average value. If this is false, the take profit will remain the same as initially set. |
[5.2] Take Profit [5.3] Stop loss | Add spread to take profit Add spread to stop loss | Adds the spread to the calculation of take profit and stop loss. This makes the take profit comes closer to the entry price, while the stop loss goes further away. This way we can make easier, by the market conditions, to trigger the TP and harder to trigger SL, but also at the cost of profiting less and losing a bit more. |
[5.2] Take Profit [5.3] Stop loss | Take profit series on both buy/sell | Read the documentation for [X.Y] Series to compare . The only difference is the possibility to set this input to Fixed bars, which corresponds to closing the position after N bars (defined by the input Fixed take profit/bars ) have passed. N represents the number of closed bars after a position is opened . If this is set to None , then the EA will ignore the next inputs and will search the specific inputs for buy and sell defined right afterwards. |
[5.2] Take Profit [5.3] Stop loss | Math operation | Read the documentation for [X.Y] Math operation to series . |
[5.2] Take Profit [5.3] Stop loss | Value | Read the documentation for [X.Y] Value . |
[5.2] Take Profit [5.3] Stop loss | Indicator index | Read the documentation for [X.Y] Indicator index . |
[5.2] Take Profit [5.3] Stop loss | Indicator buffer on both buy/sell | Read the documentation for [X.Y] Indicator buffer on both buy/sell . |
[5.2] Take Profit [5.3] Stop loss | Bar shift/fixed value | Read the documentation for [X.Y] Bar shift/fixed value. This also is set when Take profit series on both buy/sell is set to Fixed bars and shall correspond to the amount of bars that have passed to close the position. |
[5.4] Trailing Stop | ----------------- | Trailing stop is implemented, but not documented yet. |
[5.5.1] Volume | Calculation type | Method to set the volume for trades. It can be either: - Fixed: volume the same as defined in Default lot/risk (%) input. It can be changed if you define operations to change volume on a profitable or losing operation. Otherwise, it is always the same. - Balance percentage %: volume is calculated based on the stop loss level and a percentage of your balance defined by the Default lot/risk (%) input . Say you have a balance of U$ 10,000.00 and sets the balance percentage volume as 1% of it. That means you want the stop loss to be 1% of your balance. If a tick corresponds, for example, to U$ 1.00 and the stop loss is 10 ticks away from the price, it means you would be risking U$ 10.00 as per minimum volume (let's say 1 lot). If 1% of your balance is U$ 100.00, then you could trade 10 lots in this operation, so you would risk 1% of your account. |
[5.5.1] Volume | Default lot/risk (%) | Parameter set according to the chosen Calculation type input. |
[5.5.1] Volume | Operation on loss | Mathematical operation in case the last trade is a losing trade. This is ignored in case Calculation type is set as Balance percentage % . |
[5.5.1] Volume | Volume operation value on loss | Value of the mathematical operation on loss. |
[5.5.1] Volume | Operation on profit | Mathematical operation in case the last trade is a profitable trade. This is ignored in case Calculation type is set as Balance percentage % . |
[5.5.1] Volume | Volume operation value on profit | Value of the mathematical operation on loss. |
[5.5.1] Volume | Maximum volume | Maximum volume possible after mathematical operations. |
[5.5.1] Volume | Minimum volume | Minimum volume possible after mathematical operations. |
[5.5.1] Volume | Reset to init volume on loss | Resets the volume set by a mathematical calculation to the initial volume originally defined by Default lot size after a losing trade. Has no effect in case Calculation type is set as Balance percentage %. |
[5.5.1] Volume | Reset to init volume on profit | Resets the volume set by a mathematical calculation to the initial volume originally defined by Default lot size after a profitable trade. Has no effect in case Calculation type is set as Balance percentage %. |
[5.5.2] Money | Stop calculation type | Defines the method to calculate the values to stop trading in the period. Currently only Money is available, which means that after a certain level of profit/loss is reached, it stops trading until the condition is renewed. |
[5.5.2] Money | Stop trading period | Defines the period to stop trading. It can be Daily, Weekly or Monthly. |
[5.5.2] Money | Max profit in the period | Sets the maximum profit to stop trading in the period defined by Stop trading period input. If set to 0, this parameter is ignored. |
[5.5.2] Money | Max loss in the period | Sets the maximum loss to stop trading in the period defined by Stop trading period input. If set to 0, this parameter is ignored. |
[5.6] Breakeven | Percent from price | Percentage already moved from the price to trigger the breakeven. Example: the price is at U$ 10.00 and take profit is defined at U$ 11.00. The difference is U$ 1.00. If this input is set at 90%, the stop loss will be moved to breakeven when price reaches U$ 10.90 (90% between opening price and take profit). |