Divergence EA MT4 (discontinued)

22 June 2020, 11:09
Jan Flodin
25
5 489

The main purpose of this blog is to describe and explain the input parameters of my Divergence Expert Advisor for MT4, which has been discontinued. Please have a look at the MT5 version instead.

Please check out my other divergence products for MT4:
Divergence indicatorDouble divergence scannerDivergence dashboard

There are some functions in which can take advantage of the Advanced supply/demand indicator or my Supply Demand Dashboard (you need to rent or purchase them).

I strongly recommend you to do your own backtesting and fine tuning in the strategy tester before starting to trade on a live account. Always by using the 'Every tick' option if you are using settings where intracandle activities are involved, such as trailing stop.

Input parameters

  • GENERAL SETTINGS
    • Time frame to operate on - This is intended to work as a protection so that no unwanted trades will be taken in case the timeframe on the chart is manually changed.
    • Send alert instead of opening trade - When set to 'true' an alert will be sent instead of opening a trade.
    • ADR period (days) - Average daily range over the past xx days. Default is 60.
  • TREND FILTER SETTINGS
    • Trend filter to use - List box from where you can select RSI, Bollinger, Stochastics or ** ATR. The trend filter will be used with reversal logic, hence the price must have reached for example RSI 70, or the bollinger upper bands in order for a short (bearish) trade to be opened.
    • Stochastics/RSI overbought levelThe divergence candle must form above this level in order to be valid.
    • Stochastics/RSI oversold level The divergence candle must form below this level in order to be valid.
    • Bollinger shift
    • Bollinger deviation
    • Trend period (default 20 for Bollinger)
    • ADX level
    • ADX period
    • Price type
    • Time frame - if set to 'current' then the chart time frame will be used. Otherwise the selected time frame will be used for calculating the the trend indicator values.
  • ADVANCED SUPPLY/DEMAND (ASD) SETTINGS
    • Min candles for a zone (7+)
    • Min X-factor of price travel away (ATR)
    • Min Y-factor of price travel away (zone size)
    • Limitied size of a big zone. Max factor (ATR)
    • Time frame for second ASD zone (current=disabled)
    • Time frame for TP at next zone
    • Trade only on first test of zone
    • Offset from first extremum (<=5=ATR, >5=points, 0=disabled) - Will enable the EA to trade just before the price has reached the supply/demand zone.
    • FLOSOFT SUPPLY/DEMAND (FSD) SETTINGS
      • Max bars to search for first extremum - Default is 200. Will search for extremum xx bars back in time. The higher the value the more system resources will be needed.
      • Min. amount of bars between extremums - Default is 12. The higher the value the stronger the setup.
      • Neckline candle max offset % - You can set how many percentage the neckline candle can deviate from the exact middle point of the 2 top/bottom candles (extremums). If there are for instance 20 candles between the 2 extremums then setting a value to 50 (percent) will mean that the neckline candle (candle number 10) cannot be more than 5 candles to the left or right of the middle which is 10. Using this option will make it a more clear U/V formation for those who desires that for their trading strategy.
      • Offset from first extremum (<=5 = ATR, >5 = points) - If set to a value lower than 11 then the ATR (period 14) will be used and multiplied with the value given here.
      • Use offset only when above/below first extremum - 'true' or 'false'. If set to 'true' then the second extremum's candle high/low price must exceed the first extremum.
      • Algorithm to use - Listbox with 3 selections.
      • Speed - Default is 1.5. The higher the value the stronger the price move from the base must be.
      • Signal only if high/low price inside zone - Signal only of previous candle had its high/low price inside the zone.
      • Signal only if zone was untested - Signal only if first test of zone.
      • Cancel zone if tested before this amount of candles - If the high/low price reached the zone withing these amount of candles the zone will not appear in the dashboard.
    • GENERAL DIVERGENCE SETTINGS
      • Main oscillator
      • Enable divergences - a list of 5 oscillators/indicators which you can select from if you have set Main oscillator to Multi mode.
      • Amount of concurrent divergences to look for (if Multi mode)
      • Time frame for next divergence(s) - Default is current. This setting will be used if Amount of concurrent divergences above is set to > 1. If for instance you trade on a M30 chart and change this setting from current to H1 then the next divergence(s) must occur on the H1 time frame. *** for the next version this will also apply if single mode and the value is set to something else than current. Example: the EA is setup to trade MACD divergences. The chart time frame is H1 and the value here is H4. In this case there must be a MACD divergence on H1 and H4 at the same time.
      • Divergence candle shift - Set to 2 or higher for a stronger confirmation of the possible reversal/trend continuation (confirmed divergence). By having it set to 1 you will catch the possible movement earlier (unconfirmed/pending divergence). On the other hand, the signal is less reliable. You can also set it to 0 for catching "early" divergences. This means that the alert will come directly upon candle open instead of waiting for the slope in the indicator to change direction (candle shift 1 or 2), which means that the price must show at least some sign of reversal. Please be aware though that this will lead to more false signals.
      • Bars to check (divergence depth) - Bars back in time to check for divergence.
      • Min. bars to check (0=disabled) 
      • Ignore wicks on divergence candlesDivergence will be based on open/close price instead of high/low price.
      • Amount of consecutive divergences (used in single mode) - If set to > 1 then there has to be this a divergence on the last xx candles. When you use a value higher than 1 you will need to set the value in the 'Divergence candle shift ' parameter to 0.
    • REGULAR DIVERGENCE SETTINGS (trend reversal)
      • Trade regular True or False.
      • Use trend filter - True or False.
      • Use ADX - The ADX value must be below the level you have set.
      • Use moving average filter -  When enabled then the price must be above/below the MA value for the period you have set in the input parameter under the 'MOVING AVERAGE (MA) FILTER SETTINGS' section.
      • HIDDEN DIVERGENCE SETTINGS (trend continuation)
        • Trade hidden True or False.
        • Use trend filter True or False.
        • Use ADX - The ADX value must be above the level you have set.
        • Use moving average filter - When enabled then the price must be above/below the MA value for the period you have set in the input parameter under the 'MOVING AVERAGE (MA) FILTER SETTINGS' section.
      • TRADING FILTERS
        • Open buy order True or False.
        • Open sell order True or False.
        • Additional entry condition: List box with additional entry conditions:
          • Advanced supply/demand - The the high/low price of the divergence candle must be within a supply/demand zone in order for an order to be opened.
          • Flosoft supply/demand (FSD)The the high/low price of the divergence candle must be within, or close to, a supply/demand zone in order for an order to be opened.
        • Maximum allowed slippage in points - Please note that not all brokers/account types support slippage control.
        • Maximum allowed open/close spread in points (0 = not used) - Can be set to avoid taking trades with high spread directly after midnight market opening or at news releases. Useful for those with variable spreads. The default settings of 50 is for currencies. 
        • Bars to wait for next trade - Default is 1 which means that the EA can trade again (if no open orders) on the bar following the bar where the last trade was closed. Setting it to 0 means that a new trade will be opened directly after the previous has been closed (if there is still a valid signal). Let us take the example that we have this setting set to 1. If we for instance had an order on a H1 chart which was closed at 13:10 then, in case there is a new divergence signal, a new order will not be opened directly at 13:10 but at 14:00. If you had it set to 2 then at 15:00 and so on. The original idea with this setting was when using the EA for scalping (small and quick profits). In this case it will very often come to the scenario that the EA will open and close (with profit) the order on the same bar. We might then like to avoid opening another order again on the same bar.
        • Enable trade time filter (your broker's server time) - Time filter for opening trades.
        • Trade from/to time - Hour and minutes from/to.
        • Stop time Friday (hh:MM, 00:00=disabled) - Hour and minut when to stop trade on a Friday.
        • Volume average period (0=volume filter disabled) 
        • Volume over average (percent) 
        • MONEY MANAGEMENT (levels are in points)
          • Risk in percentage (>0 = auto lot) - If set to 0 the Manual lots value will be used. If set to > 0 then the EA will use money management if combined with a stop loss. The account free margin (in the deposit currency) is used for the risk calculation. The risk calculation might not work properly with metals and indices. Please use a manual lot if you are experience problems.
          • Manual lots - Will be used if Risk above is set to 0.
        ** It is important to understand the logic and functionality of the 3 following parameters. If something is not clear then please contact me by sending me a private message (PM).
          • Max allowed balance drawdown % (100=disabled) - This function will prevent opening of new trades on other charts where the EA is running if your accumulated floating loss (compared with the current balance) is less than xx%. If the 'Close orders' parameter (explained below) has been set to False then already opened orders on all charts will continue to run. Swaps and commissions are not calulated to the floating loss.
          • Orders with this Magic number (0=all) - With the default value (67) the EA will only check open order where the Magic number starts with 67. So if you have other EAs running with open orders then they will not be taken into consideration.
          • Close orders - If set to True then all orders, where the magic number starts with the value you have set above, will be closed immediately when the Max allowed % has been reached.
        • POSITION MANAGEMENT (levels are in points)
          • Type of stop loss/exit - List box with the following selections:
            • Fixed
            • At divergence candle high/low - Stop loss will be set at candle high/low + the amount of points that you have specified in the ' Offset in points...' parameter.
            • Advanced supply/demand - Stop loss will be set the zone's outer border + the amount of points that you have specified in the ' Offset in points...' parameter.
            • ATR SL - The current (close price of divergence candle) ATR level multiplied with the value you have set below in the 'Multiplier for stop loss' parameter under the ATR SETTINGS section.
            • Flosoft supply/demandStop loss will be set the zone's outer border + the amount of points that you have specified in the ' Offset in points...' parameter.
          • Fixed stop loss (<0 = ADR %) - When a negative (minus) value will be put here then the ADR% logic will be used.
              • Take profit method - List box with the following selections:
                • Fixed take profit
                • Trailing stop – starts to trail when profit>=0
                • ATR TP
                • Risk/Reward (based on SL)
                • Advanced supply/demand - Take profit will be set at the next  zone's inner border.
              • Fixed take profit (<0 = ADR %) - When a negative (minus) value will be put here then the ADR% logic will be used. Values which work for most pairs are -15 for H1, -25 for H4 and -40 for D1.
              • Trailing stop  (<0 = ADR %) - Will trail the stop loss constantly with the distance you have set as soon as the trade is in profit. When a negative (minus) value will be put here then the ADR% logic will be used. Traling stop will not work properly when using the Close half option.
              • Trailing step - If the trailing step is set to 0 then the trailing stop will be adjusted each 2nd second. Else the trailing stop will be adjusted every time the price has moved the amount of points you have set here.
              • Risk/Reward ratio - You need to set the “Take profit method” parameter to Risk/Reward in order for this value to have any effect. You need also to set “Type of stop loss/exit” to Fixed and a fixed stop loss value. A stop loss value of 200 points and a R/R ratio of 1.5 would mean that the take profit level would be automatically set to 300 points when an order is opened.
              • Break-even (0 = disabled)
              • Break-even trigger - The price has to reach this level (calculated from the opening price) in order for the break-even to be set.
              • Offset (<0=ADR%, >0=points, 0=disabled) - Additional distance for for the stop loss (if it has been set to 'At divergence candle high/low').
            • CLOSE HALF SETTINGS
              • Close half position - Combo box with the selections below. Please make sure that your account supports part close of orders before you use this option.
                • Disabled - Default value.
                • ATR - The current (close price of divergence candle) ATR level multiplied with the value you have set below in the 'Multiplier for close half' parameter under the ATR SETTINGS section. When you have set this option then a line showing the level will be drawn on the chart.
                • At first TP level - If you select this option you will also have to adjust the value in the 'First TP level...' parameter below.
              • Move to break-even after close half - True or False.
              • First TP level for Close half (<0 = ADR %)
            • ATR SETTINGS
              • Period
              • Multiplier for take profit and close half
              • Multiplier for stop loss
              • ATR multiplier for trend filter
            • MACD AND OsMA SETTINGS
              • Fast MA - Default is 12
              • Slow MA - Default is 26
              • Signal MA - Default is 9
            • STOCHASTIC SETTINGS
              • K
              • D
              • Slowing
              • MA methodDefault is 'Simple' (SMA).
              • Price type
              • CCI AND RSI SETTINGS
                • RSI period
                • CCI period
                • MOVING AVERAGE (MA) FILTER SETTINGS
                  • Slow MA 
                  • Fast MA (0 = disabled)
                  • Slow/fast MA method - Default is Simple (SMA).
                  • Slow/fast MA price type - Default is Close.
                  • MA time frame - It is recommended to set this to one time frame higher than the divergence time frame.
                • CHART OBJECTS
                  • Bullish color
                  • Bearish color
                  • ALERTS (if alert instead of trade is enabled)
                    • Set to 'true' for each alert type you would like to activate.
                  • Magic number - If using the EA on the same symbol on multiple charts (typically with different time frames, or same time frame but one chart trading Hidden only and another trading Regular only) then it is important that the Magic number parameter has a different value. If not then trades on the same symbol will interfere with eachother.
                  • Order comment - This parameter is not used. The comment will be set automatically. For instance "Reg [divergence indicator] M30" or "Reg [first indicator]/[second indicator]/[third indicator] M30" if you have set ' Amount of concurrent divergences to look forhigher than 1. The amount of characters in the order comment is by design limited to 32. So if you have set this to a value higher than for instance 4 then the text in the order comment will be cut at 32 characters. By some brokers it might even come be empty.
                  • Show comments on chart - Will show information about the EA in a panel which can be moved on the chart.


                  Files:
                  Share it with friends: