Multi oscillator divergence EA (discontinued)

12 December 2017, 17:35
Jan Flodin
4
2 905

The main purpose of this blog is to describe and explain the input parameters of my Divergence EA.

Please note that the recommended usage of this EA is for the experienced trader who would like to use an existing setup which has been traded manually and successfully for some time.

Whenever there is an available update of the EA I recommend you to wait with updating until all open positions by the EA have been closed. You can update it without removing the previous version from the chart. Before updating I also recomend to turn off AutoTrading and after the update please control that the input parameters have not changed on each chart where the EA is loaded. Then you can turn on AutoTrading again.

There are some functions which can take advantage of the Advanced supply/demand indicator. It will only work though if you have rented this product. It is then important that it has been loaded on each chart where you have loaded the EA and intend to use any of the involved functions. It is also important that the parameter 'use PIN' in this indicator has been set to True.

If you don't already have an existing strategy which you have manually traded for some time, and would like some help to find some setups, I recommend you to start with the preset (.set) files which I have attached in the end if this blog. The test are performed from 2015.01.01. I strongly recommend you though to do your own backtesting and fine tuning in the strategy tester. The preset files should not be considered as the holy grail. They are more meant to show the way. I am only providing with preset files for the major currency pairs. If you would like to run tests on other pairs or indices then please use the existing files as templates. That there for instance is no file for AUDUSD M30 does not have to mean that there is no valid setup. It is just something that I have not tested. I am using the averaging down (cost averaging) function in the set files, without stop loss. So there is a higher risk involved. If used with averaging then a leverage of 400:1 or higher is highly recommended.

Input parameters

  • GENERAL SETTINGS
    • Time frame to operate on -  Default is 'current'. This parameter can be changed to the time frame you intend to trade on (= the chart time frame). You will then lock the EA to trade only on this time frame. This is intended work as a protection so that no unwanted trades will be taken in case the time frame on the chart was 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 or Stochastics. The Stochastics filter will use the additional condition that the singla line must have crossed the main line.
    • RSI filter method - List box from where you can select if the RSI filter must be applied on both extremums or just one of them.
    • RSI overbought and oversold levels for regular and hidden divergences - The divergence candle must form above/below these levels in order to be valid.
    • Stochastics overbought level
    • Stochastics oversold level
    • ADX level
    • Bollinger shift
    • Bollinger deviation
    • 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.
    • Enable RSI filter also on all lower time frames - This parameter will only be used if RSI has been selected as Additional condition under the Averaging section.
  • GENERAL DIVERGENCE SETTINGS
    • Main oscillator
    • Enable divergences - a list of 11 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)
    • Divergence candle shift (must be >0) - When set to 1 (unconfirmed/pending divergence) you will be able to catch the movement earlier. On the other hand, the signal is less reliable.
    • Divergence on candle shifts <= shift above - If set to True then the also divergences newer (lower candle shift) then the setting above will be valid. Please note that in this case also unconfirmed divergences will be searched for. This setting will not be used if Divergence candle shift has been set to 1.
    • 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.
    • Bars to check (divergence depth) - Bars back in time to check for divergence. As a rule of thumb, you can set it to your slow EMA setting for OsMA , MACD and Awesome and to the Period setting for the other oscillators. Then add 2 bars to that.
    • Use divergence price strict mode - Please see explanation on the first screenshot under the product description.
    • Min/max close percent away from high/low (0=disabled) - Please see explanation on the second screenshot under the product description.
    • Trade only if divergence candle high/low crossed - If set to 'true' a market order will be placed when price has reached the divergence candle high/low (+ offset below).
    • Maximum bars signal is valid for - The market order will not be placed after this amount of bars.
  • REGULAR DIVERGENCE SETTINGS (trend reversal)
    • Trade regular
    • Use trend filter
    • Use ADX
    • Use moving average filter
    • Additional entry signal: List box with addition entry conditions. At this time there is only one condition supported:
      • 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.
  • HIDDEN DIVERGENCE SETTINGS (trend continuation)
    • Trade hidden
    • Use trend filter
    • Use ADX
    • Use moving average filter
  • TRADING FILTERS
    • Open buy/sell order
    • 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. For closing of orders this filter is only used on combination with averaging and when Virtual TP has been set to 'true'.
    • 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.
    • Minutes to wait after London and NY opening - Default is 30. This makes it possible to pause the EA during this amount of minutes after the London and NY session openings. This option is more useful when trading indices.
  • NEWS SETTINGS
    • Enable news filter - True or False
    • News provider - List box where you can select from the following news providers (URL must added to the allowed WebRequests. Please see the last screenshot under the product description):
    • Update interval (time frame): Default value is 'current'. This means the current chart time frame. So if you for instance are trading on a H1 chart the news will be updated each hour.
    • News currencies (symbol currencies if empty) - Here you can specify additional or other currencies (the chart currencies must also be added if you would like to include them as well). Could for instance be set to EUR if you are trading DE30 (DAX). The currencies must be separated by a comma. If left empty then the chart currencies will be used. If the chart is a EURUSD chart then USD and EUR news will be used.
    • Events - List box parameter with 5 selections:
      • Custom - Custome events. Must be defined in the next parameter.
      • HIGH - High impact news only.
      • HIGH,MED - High and medium impact news.
      • HIGH,MED,LOW - High, medium and low impact news.
      • SPEECH - Speeches only
    • Custom events, if selected above (separated by comma) - Here you can filter on custom events. For instance putting here Non-Farm, in combination with having 'Custom' selected above, will stop from opening new trades only at NFP (Non-Farm Payrolls) news.
    • Pause before news (minutes)
    • Pause after news (minutes)
    • Chart offset in hours (0=automated)
    • Draw news lines on chart - True or False. Lines are drawn on the candle on which time span the news will be released (your broker's time).
    • Draw only future news lines - True or False.
    • Line color for low impact
    • Line color for medium impact
    • Line color for high impact
  • 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. If Averaging is enabled the risk will not be calculated correctly. Therefor it is important for you to do your own risk calculation depending on the Lot multiplier and Amount of averaging orders settings.
    • Point value for risk percentage - Default is 1. Should normally not be changed. Only in some rare cases where the broker has unconventional tick values for CFD:s a setting of 0.1 could be used.
    • 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 is over this value. If the 'Close orders' parameter (explained below) has been set to False then already opened orders on all charts will continue to run (including averaging orders. The averaging mechanism will also continue to open new orders if necessary).
    • Orders with this Magic number (0=all) - Default value is 67. Please note that in my set files the Magic number is set to 67XXXX. With the default value 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 as long as the magic number doesn't start with 67.
    • 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.
  • TRADE MANAGEMENT (levels are in points)
    • Type of stop loss/exit - List box with the following values:
      • 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 from candle high/low' parameter.
      • On opposite (main) divergence - The current order will be closed and a new opposite (pending or market) order will be opened.
    • Fixed stop loss (<0 = ADR %) - When a negative (minus) value will be put here then the ADR% logic will be used.
    • Stop loss at divergence candle high/low (+ offset above) - If the price reaches this level the order will be closed. The distance from your offset setting + spread will be added.
    • Take profit method - List box with the following values:
      • Fixed take profit
      • Trailing stop – starts to trail when profit>=0
      • Risk/Reward (based on SL)
    • 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.
    • Trailing step - If the trailing step is set to 0 then the trailing stop will be adjusted each 3rd 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 in points (<0=ADR %, 0=disabled) - Distance for opening a market order (if the high/low cross option has been enabled). The spread is automatically added based on your max spread setting below. If set to 0 then the current market spread will be used instead. So if you for instance have set the offset to 10 and max spread to 15 the open price of the order will be 25 points away from the candle high/low price.
  • CLOSE HALF SETTINGS
    • Close half position - Combo box with the values below. Please make sure that your account supports part close of orders before you use this option.
      • Disabled - Default value.
      • Support/Resistance - An interpretation of Stieve Nisson's 'Three Line Break' strategy.
      • Pivot points – Select from H4, D1 or W1.
      • ATR - The current ATR level multiplied with the value you have set below in the 'ATR multiplier' parameter.
      • Pin bar
      • At first TP level - If you select this option you will also have to adjust the value in the 'First TP level' parameter below.
      • Opposite divergence - If you have a buy order open and a bearish divergence occures then half of the position will be closed.
    • Move to break-even after close half - True or False.
    • First TP level for Close half (<0 = ADR %)
    • ATR multiplier for Close half
  • MACD AND OsMA SETTINGS
    • Fast MA - Default is 12 (5 for Awesome).
    • Slow MA - Default is 26 (34 for Awesome).
    • Signal MA - Default is 9 (not used with Awesome).
  • STOCHASTIC SETTINGS
    • K
    • D
    • Slowing
    • Price type
    • Enable stochastics OB/OS filter (both regular and hidden)
  • ADX SETTINGS
  •  COMPOSITE INDEX SETTINGS
    • RSI slow period
    • RSI fast period
    • Momentum period
    • Average period 1
    • Average period 2
    • Price type
    • CCI, RSI, RVI AND ATR SETTINGS
      • Period
    • CANDLE PATTERNS FILTER SETTINGS
      • Enable pin bar filter - 'true' or 'false'.
      • Combine with RSI filter (RSI must be enabled below) - 'true' or 'false'.
      • Minimum candle size in points - Makes it possible to avoid the smallest pin bars. If you for instance trade M5 and M15, you could set it to 40 points.
      • Minimum candle body size % (0 = any body size) - The scanner will filter out dojis by default. Recommended setting is 0. But if you would like a larger body, you can set a higher value.
      • Minimum percent for tail - Default is 50. If you would like a larger tail/shadow, you can set it to for instance 60. It will give fewer signals but higher quality.
      • Only strict pin bars - True or False. A strict pin bar means that the pin bar must have another color than the previous bar and that the pin bar’s high must be higher than the previous bar's high and finally that the pin bar’s body must be within the range of the previous bar.
      • Enable Engulfing filter - 'true' or 'false'.
      • Combine with RSI filter (RSI must be enabled below) - 'true' or 'false'.
      • Min. engulfing candle body size % (0 = any body size) - A higher percentage (larger body) will give higher quality signals.
      • Min. engulfing candle size in points (0 = any size) - Only Engulfing candles (second candle) larger or equal than this size will give an alert.
      • Max. engulfing candle size in points (0 = any size) - Only Engulfing candles (second candle) smaller or equal than this size will give an alert.
    • 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.
    • AVERAGING SETTINGS
      • Enable averaging - 'true' or 'false'.
      • Show information panel -  'true' or 'false'. Please see attachment below. 
      • Averaging method - Select from TIMEFRAME or DISTANCE
      • Time frame (if set to TIMEFRAME  above) - There must be a new candle for the selected time frame and min. distance reached in order for an averaging order to be opened.
      • Additional condition - Listbox from where you can select from the following options:
        • Divergence - with this option you will instruct the averaging function not only to wait for the proper distance but any of the divergences you have selected must also occur. The averaging method must be set to TIMEFRAME and typically to the same time frame as you are trading on the chart. You might also consider using a lower value for the Distance. An averaging order will only be opened for confirmed divergences (candle shift 2).
        • RSI - with this option you will instruct the averaging function not only to wait for the proper distance but also that that RSI must be in overbought/oversold area. The following parameters under the Trend filters settings section will be used for this purpose:
          • Regular divergence RSI overbought level
          • Regular divergence RSI oversold level
          • Period
          • Price type
          • Time frame
          • Enable RSI filter also on all lower time frames
        • Advanced supply/demand - It works in the way that a new averaging order will be opened if first of all the distance has been reached and then, as a second condition, that the high/low price of the previous candle was above/below the beginning of the supply/demand zone. If there is no next supply/demand zone then the last zone will continue to be used which means that the next averaging order will be opened using only the distance condition.
        • First averaging order distance (0=disabled)
        • Min. distance for next orders (<0 = ADR %) - If you use a negative value here then the distance must have reached 50 pips (100 / 2) before an averaging order will be opened. This using the example that ADR for the last 60 days is 100 pips.
        • Distance multiplier
        • Use ADR (Average Daily Range) - This parameter has been removed in version 3.1. The parameter 'Min. distance for next orders (<0 = ADR %)' is now used instead  - 'true' or 'false'. ADR is calculated based on the sum of each days move (high-low) divided with the amount of days.
        • ADR divider - This parameter has been removed in version 3.1. The parameter 'Min. distance for next orders (<0 = ADR %)' is now used instead - Default is 2. If ADR for the last 60 days is 100 pips then the distance must be at least 100 / 2 = 50 pips before an averaging order will be opened.
        • Lot increase method - Select from MULTIPLIER or INCREMENT.
        • Lot multiplier/increment - if Multiplier is selected above and this value is set to for instance 1.4 then an initial 0.1 lot order will generate a first 0.14 lot averaging order. If Increment is set above and this value is 0.02 then the first averaging order will be opened with 0.12 lots. Second 0.14 and so on.
        • Take profit method - Select from POINTS or MONEY.
        • Profit in Points or Money (0 = break even) - If value is set to for instance 10 then if Points is selectedabove the averaging order basket will be closed when in 10 points profit. If money then when 10 in profit in the account currency.
        • Wait for candle close (Virtual TP must be True) - Will wait for candle close before closing orders.
        • Virtual TP (always used with Money. Must be True for FIFO) -  'true' or 'false'. If set to True a green line will appear at the TP level. If False then all orders will have a broker TP. I would recommend setting Virtual TP to false. Then the trades will be closed even if your PC/VPS have a power failure or internet connection problem or any other related problem. With TP and SL already sent to the broker you are always protected even if the broker's server should have a failure. You would then be able to file a complaint if a TP or SL was not triggered for some reason, or triggered with big delay.
        • Maximum amount of averaging orders - Amount of averaging orders to open.
        • Close all orders at max - All orders will be closed when the last order has been opened and the price has moved yet a distance unit.
        • Close only first order at max (must be True above)
        • Lock order distance (0=lock disabled) - Possibility to enable an Averaging lock (hedge) order. If this is set to for instance 500 (points) and the maximal number of grid levels have been opened, the EA will issue a pending (buy/sell stop) lock order 500 points above/below the opening price of the last averaging order. The take profit levels will remain though until the lock order has be activated (opened). As soon as this happens all take profits will be removed and it will make the whole position neutral. Hence the loss amount of the time when the lock order was opened will stay the same since the lot sise of the lock order will be the same as the sum of the lots for the already opened orders. After that the EA does nothing and the trader will have to manually deal with the trades.
      • 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 for' higher 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 the upper left corner of the chart.


      Preset files

      The attached preset files below also contains the report files. The tests are performed on a $ 1.000 account. The period is 2015.01.01 - 2019.12.31.

      • I have removed a couple of files in version 3.1 due to higher risk. You will be able to recognize which files by looking at the number in the beginning of the file name
      • I have added some new 'General' files in version 3.1


      Share it with friends: