Download MetaTrader 5

Watch how to download trading robots for free

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

2015.03.26 12:43
Experts

Ilan 1.6 Dynamic HT - expert for MetaTrader 5

| English Русский 中文 Español Deutsch 日本語 Português

Published by:
Vasiliy Sokolov
Views:
10258
Rating:
votes: 42

Real author:

Unknown.

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

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!


Inputs and Parameters

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.

Parameter NameValue
default
Description
Basic parameters
LotExponent  1.4
 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  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   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:

  • Every Tick. Test the EA in this mode if you are using trailing stop and want to have an accurate exit by TakeProfit, CCI Stop and EquityStop.
  • 1 minute OHLC. This mode is a compromise that combines the high testing speed and accuracy of signals.
  • Open prices only. This is the fastest mode. Due to the virtualization, TakeProfit trigger only at the bar opening in this mode. CCI Stop and EquityStop trigger the same way. However, in many cases such an artificial approximation brings a better result than testing in the "Every tick" mode.

The algorithm of Ilan 1.6 Dynamic is successfully tested both in the normal mode and in the Random Delay mode.

Recommended symbols

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:

  • DefaultPips - 12;
  • TakeProfit - 10;
  • slippage - 3;
  • StopLoss - 50.

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_ht.mq5 - the basic module. It contains EA's trading logic. Tag "HT" in the name indicates that the Expert Advisor requires the HedgeTerminalAPI library for operation. This is the only file which should be saved to the folder terminal_data_folde\MQL5\Experts\, all other modules should be saved to terminal_data_folder\MQL5\Include\.
  • prototypes.mqh - the file of prototypes required for interaction with the library.
  • drawhedgeposition.mqh - traces (draws) EA's trades the way similar to MetaTrader 4 (see the first screenshot). Bi-directional positions are opened parallel to each other rather than following one after other like in MetaTrader 5.
  • environment.mqh - the module of the Expert Advisor's trading environment. Collects all the necessary trading information required for the EA. It allows you to find out how many positions the EA has opened, what is their profit/loss and many other useful details.
  • testertable.mqh - shows a simple table of all open positions of the Expert Advisor in the strategy tester. If you want the EA's positions to be displayed in the visual table in real time, use the HedgeTerminal panel.
  • indicators.mqh - the module of indicators. It provides a simple interface to access the data of indicators.
  • tradestate.mqh - the module of the Expert Advisor's trading state. In MetaTrader 5, it may take some time before an executed order is added to the order history, from which it can be analyzed. This module helps to correctly wait for an order to be added to history.

How to visualize the operation of the Expert Advisor and control its operation through manual operation?

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

Fibonacci Pivot Points Fibonacci Pivot Points

The indicator uses Fibonacci multiples to determine significant levels of support and resistance for the current trading session.

Fractal ZigZag Fractal ZigZag

This indicator is MQL5 version of FractalZigZagNoRepaint, it displays swing highs and lows.

KeyFinder KeyFinder

This script finds DeMark pivot points, displays them on the chart and indicates their dimensions.

KeyLevels KeyLevels

The indicator of price levels with round numbers 00, 20, 50, 80.