The underlying algorithm of Ilan Dynamic 1.6 HT is simple. It is based on price averaging, with a gradual increase in the volume of each trade.
For example, if after the opening of the first long position the price goes down and exceeds a certain range in points, a new long position with a larger volume will be opened.
Thus, the average entry price of Ilan Dynamic stays close to the current market price. Therefore it is only needed to wait for a small price rollback and close all open positions with profit using TakeProfit. The overall picture of entries performed by Ilan 1.6 Dynamic corresponds to this screenshot of the MetaTrader 5 Strategy Tester:
As you can see, the price went against three Buy positions, but after a small rollback all the three positions were closed with a significant profit. The screenshot also shows the TakeProfit levels (green horizontal lines) and the StopLoss levels (red horizontal lines).
The Expert Advisor dynamically calculates the price levels for averaging depending on the price range between the high and low price within the range of the last few bars. The word "Dynamic" in its name points to this fact.
In addition to TakeProfit, Ilan 1.6 Dynamic allows the use of the classical StopLoss, trailing stop, exit by time, exit by the CCI indicator and exit by a specified Equity level of all trades.
Test results of Ilan 1.6 Dynamic can vary greatly depending on the selected timeframe, the testing period, the instrument, the broker and the initial conditions.
Therefore the EA requires a thoughtful selection of parameters and markets on which it will trade. Nevertheless, it is possible to get some consistent results even on a short history by using the default settings. Here is a typical equity and balance chart generated by the Expert Advisor:
Warning: Floating profit/loss or Equity of Ilan 1.6 Dynamic can greatly differ from its balance, which is reflected on the chart. If the price moves without rollbacks, its Equity drops and eventually this trading strategy may lead to MarginCall and ruin your deposit. Work using Ilan 1.6 Dynamic only during flat. Use its lot exponent with caution!
Ilan 1.6 Dynamic is optimally configured by default. Most of its parameters are not used in this mode. However, you can customize the options.
Use the below table to configure the parameters to your liking.
||Lot multiplier when opening the next position. For example, when LotExponent = 1.4 and Lots = 0.1, the first opened position will have lot 0.1, the second averaging position will have lot 0.2 (0.1 * 1.4^2), the third one - 0.3 (0.1 * 1.4^3), the seventh lot 1.0 (0.1 * 1.4^7). This parameter should be changed with caution. Its values range from 1.0 (ultra-conservative trading) to 2.0 (super-aggressive trading);|
|MaxTrades||10||How many positions can be opened in one direction. If the limit on positions is exhausted, new positions are not opened, while old positions are closed by a suitable exit condition (depends on settings).|
|DynamicPips||true||True if a dynamic price range is used.|
|DefaultPips||120||The default level of a price channel in pips.|
|Glubina||24||Ilan 1.6 Dynamic calculates the price range between High and Low over the lat few bars. The parameter indicates how many bars to use for such a calculation.|
|DEL||3||The ratio indicates what part of the price range to use in order to define the next Buy or Sell level.|
|Lots||0.1||The lot size of the first trade.|
|lotdecimal||1||The number of decimal places in lot calculation. 0 - normal lot (1.0), 1 - mini lot (0.1), 2 - micro lot (0.01)|
|TakeProfit||100||The Take Profit level in points from the current price at which all open positions are closed.|
|slippage||30||The level of the maximum allowable slippage in points.|
|MagicNumber||2222||Expert Advisor's magic number.|
|Parameters defining market entry signals|
|RsiPeriod||14||The RSI indicator period.|
|RsiMinimum||30.0||If RSI is below the current level, Buy trades will not be performed.|
|RsiMaximum||70.0||If RSI is above the current level, Sell trades will not be performed.|
|Use and configuration of the classic StopLoss level|
|UseStopLoss||false||By default, StopLoss level is not used, but you can enable it by setting the value of this variable to true.|
|StopLoss||500.0||The StopLoss level in points (the default value is set for 5-digit quotes).|
|Use and configuration of Equity Stop|
|UseEquityStop||false||True if you want to close positions if the total loss of all positions reaches a certain percentage of the maximum reached profit.|
|EquityPercent||1.0||Percent of profits of all open positions from the current account equity. If this percentage is exceeded, exit by Equity-stop is activated for all positions.|
|TotalEquityRisk||20.0||Percent of loss of the maximum reached equity, at which the EA will exit from all existing positions.|
|Use and configuration of TrailingStop|
|UseTrailingStop||false||By default, Trailing Stop is not used, but you can enable it by setting this variable to true.|
|TrailStart||100.0||The level of the weighted average profit of all positions in points. Once this level is exceeded, trailing stop will be activated.|
|TrailStop||100.0||Level in points between the current price and StopLoss that should be trailed.|
|Use and configuration of CCI based stop|
|UseCCIStop||false||By default, CCI based stop is not used, but you can enable it by setting this variable to true|
|CCIPeriod||55||The period of CCI.|
|CCILevel||500||If the value of CCI > CCILevel (500 default), all short positions are closed. If CCI is lees than -500 (default), all long positions are closed.|
|Use and configuration of time based exit|
|UseCloseByTime||false||By default, exit by time is not used, but you can enable it by setting this variable to true.|
|MaxTradeOpenHours||48||The number of hours since the opening of the first position after which all positions are closed. Only trading hours are taken into account. Weekends and holidays time ignored.|
Testing Modes. Optimal instruments and timeframes.
Ilan 1.6 Dynamic has been created to profit primarily from short-term price movements. Its optimum timeframe is a 15-minute chart (M15). The default settings should be used for 5-digit quotes. The EA supports testing in the following modes:
The algorithm of Ilan 1.6 Dynamic is successfully tested both in the normal mode and in the Random Delay mode.
It is recommended to use Ilan 1.6 Dynamic on all currency pairs that have long flat (no trend) periods. Good pairs are EURUSD, USDJPY, GBPUSD, USDCHF, EURCHF and other majors. The EA's settings are optimized for 5-digit quotes. If you want to use the EA on 4-digit pairs, first reduce the following parameters ten times:
How to compile the EA and make it work (important!)
Ilan 1.6 Dynamic actively uses a grid of orders and individual position management.
Therefore it requires a special virtualization which allows to work in the MetaTrader 5 environment similar to MetaTrader 4. To do this, it uses calls of the HedgeTerminalAPI library functions, working in the environment provided by the library. Read the article "Bi-Directional Trading and Hedging of Positions in MetaTrader 5 Using the HedgeTerminal API, Part 1" to learn how to use the library. If you want to modify the EA's trading logic, read this article to understand how the EA's code works.
Before you begin, you need to download the HedgeTerminalAPI library on your computer. After that, copy the software modules used by the Expert Advisor on your computer (attached hereto). Here are the details of these modules.
Ilan 1.6 Dynamic manages multiple unidirectional positions at a time. All these positions are displayed in MetaTrader 5 as one net position. On order to have easy access to the management of EA's positions, as well as to have its trading state at each time point, you should also install the demo panel HedgeTerminal. After its launch, it will display the positions of the Expert Advisor the following way:
For more details, please read the article Bi-Directional Trading and Hedging of Positions in MetaTrader 5 Using the HedgeTerminal API, Part 1.
Translated from Russian by MetaQuotes Software Corp.
Original code: https://www.mql5.com/ru/code/12220
The indicator uses Fibonacci multiples to determine significant levels of support and resistance for the current trading session.Fractal ZigZag
This indicator is MQL5 version of FractalZigZagNoRepaint, it displays swing highs and lows.