The X - Universal EA

The X - Universal EA

13 September 2016, 17:15
Vladislav Andruschenko
2
298

Type : Universal Advisor

Grade : Automatic trading robot with integrated strategies

Terminals : MT4 and MT5

Features :

This Expert Advisor includes all the useful functions that have been used in all the Expert Advisors including the function of averaging.

Uses signals from 11 standard indicators included in MetaTrader 4 package.

The function of averaging allows bringing an unprofitable position to profit by creating a grid of positions in the price movement direction. If the price moves against a position, the averager will open additional positions on the basis of your settings, thus it increases the volume and sets a common take profit for all positions by the given symbol.

The martingale function allows using the standard martingale mode.

Trailing stop, break even, trading time, auto lot, closing by total profit/loss. All these function are available in the full version of the Expert Advisor.


References :

Demo MT4      Demo MT5

MT4 FULL        FULL MT5

Discussion

Open source MT4        Open MT5 code

Official page

 


Preferences


SETTING SALES STRATEGIES

  • TypeFilling - fill orders for Type regalmentu broker. Auto - auto-detect the type of fill, fill type orders under the rules of your broker

  • TypeTradeBUYSELL - Select the type of position to open (BUYSELL, OnlyBuy, OnlySell);

  • RoundingDigits - Rounding opening price and stop loss, take profit - for certain characters;

  • SetMinStops - Automatic reduction of the established stops (stop loss, take profit, treylingstop, distance, breakeven) to the lowest possible level on the server;

  • The shift - With a bar to take a 0 - 1 at the current - with closed;

  • IndSigToTrade - Select the type of signal;

  • TF_IndSigToTrade1 - Selecting a timeframe for the signal;

  • The FILTER _ IndSigToTrade2 - Select the type of signal to filter;

  • The TF _ IndSigToTrade2 - Selecting a timeframe for the filter;

  • The FILTER _ IndSigToTrade3 - Select the type of signal to filter;

  • The TF _ IndSigToTrade3 - Selecting a timeframe for the filter;

  • ReverseSignal - to true - Inverting the signal strategy;

  • MinuteToOpenNextPosition - The number of minutes for the opening of the next transaction on the indicator signal.

    This parameter counts the number of minutes elapsed from the last open position. Allows

    filter transactions using ONlyOnePosbySignal = false

    OpenOppositePositionAfterStoploss - opening opposite positions at the close of the current postoplossu. It allows you to open an opposite position immediately after receiving stoploss predyduscheysdelki without using the indicator signals

    MAX_BUY_POSITION MAX_SELL_POSITION - Maximum number of transactions Buy and Sell


MAIN FEATURES OF TRADE

  • VirtualStops - Virtual foot instead of the real true - the broker can not be seen stoploss and take profit of transactions on all functions advisor !!!!;

  • StopOrderUSE - use pending orders;

  • StopOrderDeltaifUSE - distance for pending orders;

  • Game Magic - Magic number;

  • Of StopLoss - Stop-loss, 0 - not used;

  • TakeProfit of - Take Profit, 0 - not used;

  • Slippage - Slippage;

  • MarketWatch The - trade regime for MarketWatch true = first exhibited items / orders, without stops, then are modified - for some brokers;

  • ClosePosifChange - close the position at the opposite signal;

  • ONlyOnePosbySignal - Play alone or buy and / or a sell position 1;

  • OnePosPerDirection - Opening 1 transaction on the 1 line;

  • OnlyOnePositionPerMagic - Opening 1 position in 1 Magick;

  • MaxSpreadToNotTrade - maximum spread at which the advisor can open new transaction;

  • MinSpreadToNotTrade - Minimum spread, in which the advisor can open new transaction;

SETTINGS AND AVTOLOTA Martingale


  • Lots - Fixed lot;

  • DynamicLot - Dynamic Lot;

  • LotBalancePcnt -% of the deposit;

  • MaxLot - Maximum lot in the calculation;

  • By Martin - 1 If it is not used, martin factor to the next deal after losing money;

SETTING TIME WORK


  • The Work _ the SETTINGS - = on, off on it if:

  • OpenHourMonday - hour opening of trading on Monday;

  • OpenMinuteMonday - minute opening trading session on Monday;

  • OpenHour - opening hour of trading;

  • OpenMinute - minute opening;

  • CloseHour - Hour of the close of trading;

  • CloseMinute - Minute of the close of trading;

  • The Days - (Choice of trading days), separated by commas;

  • TradeStartStop - on, off;

  • TradeStartStopFriday - on, off (if on - then, according to Trade Friday and CloseFriday, if off then according TradeStartStopHour, if in 5 Days is if);

  • OpenHourFriday - hour opening of trading Friday;

  • OpenMinuteFriday - Minute of the opening of trading Friday;

  • CloseHourFriday - Hour of the close of trading Friday;

  • CloseMinuteFriday - Minute of the close of trading Friday;

  • CloseFriday - on, off (if on the closing regardless of status (profit or loss) (if off the open positions are closed according to the algorithm);


TREYLINGSTOP


  • TrailingStopUSE - Use treylingstop;

  • IfProfTrail - Use only of profitable positions - bezubytka mode;

  • TrailingStop - Distance trailing = 0 - the minimum allowed;

  • TrailingStep - Step distance;


TREYLINGSTOP FOR PARABOLIC


  • TrailingStopSAR - Use treylingstop;

  • Step - increment of the stop level, usually 0.02;

  • Maximum - maximum stop level, usually 0.2;


CLOSING OF THE GENERAL profit and loss account


  • TypeofClose - type of closing for profit;

  • CloseProfit - Close if +;

  • Prifitessss - Number of units (depending on TypeofClose choice) to close the profit;

  • CloseLoss - if close -;

  • Lossss - Number of units (depending on the choice of TypeofClose) to cover losses;

SETTINGS bezubytka


  • MovingInWLUSE - Transferring the position to breakeven;

  • LevelWLoss - We transfer stoploss at + LevelWLoss points;

  • LevelProfit - When the deal went into LevelProfit plus points;


Averaging


  • UseAverDolivkaOrderinOne - to true number of orders is considered common and topping up and equalization;

  • AverageUSE - Use averaging the opening of additional orders against the trend;

  • The Distance - Distance net open positions;

  • LotsMartin - Increasing the bid for a grid position;

  • MaxOrdersOpen - Maximum number of elbows 0 - unlimited;


REFILLING the trend


  • Dolivka - Use the discovery of additional orders with the trend;

  • DistanceDolivka - distance open positions Net topping the trend;

  • LotsMartinDolivka - Increasing the bid for a grid position;

  • MaxOrdersOpenDolivka - Maximum number of elbows 0 - unlimited;




Limiting losses and profit for 1 day \ week \ Month


  • Limiting LimitFor - Restriction type day \ week \ month

  • LimitForLosses - for profit limit

  • LimitForProfits - at a loss limit


 

The list of indicators and filters

Expert Settings IndSigToTrade..FILTER_IndSigToTrade2, FILTER_IndSigToTrade3.


Moving Average (MA) (Signal 1)


The signal is calculated by the relative position of two moving averages, one of which should have a shorter period (fast MA), and the other, respectively, larger (slow MA). These parameters can be specified in the variables.


BUY signal is issued when the fast MA is above the slow and SELL signal when slow up fast. The state "no signal" is not used.


Moving Average Convergence / Divergence (MACD) (Signal 2)


It operates on four variables. Signals are also simple: BUY - the main line above the signal, SELL - the main line below the signal. "No signal" is used.


Stochastic Oscillator (signal 3)


The oscillator consists of two lines - the main and the signal that allows you to trade the signals of the intersection of these lines.BUY signal - the main line above the signal, SELL signal - the main line below the signal.


The RSI (Signal 4)

Similar to CCI and DeMarker'u. Signals are output from the overbought zone (RSIHighLevel) and oversold (RSILowLevel). So rare BUY signals correspond to the intersection of the upper level from the top down, and signals SELL - the intersection of the lower layer from the bottom up. The main condition - "no signal". The period indicator can be set in RSIPeriod parameter and calculate the price - in RSIPrice parameter.


Commodity Channel Index (CCI) (Signal 5)


all three signals are also used, but the main condition is still "no signal". The rare occurrence of trading signals corresponds to the intersection of the upper level from top to bottom (BUY) and the intersection of the lower layer from the bottom up (SELL).The upper and lower levels are determined by the value of the external parameters and CCIHighLevel CCILowLevel. Period and price calculation of the indicator values ​​are determined and CCIPeriod CCIPrice.


Williams Percent Range (WPR) (signal 6)


It should be on a par with RSI, CCI and DeMarker. BUY signal - the intersection of the overbought level (WPRHighLevel) from top to bottom, SELL signal - the intersection of oversold (WPRLowLevel) level upwards. Everything else - the "no signal". Change the setting from the outside can only display period - WPRPeriod.


Bollinger Bands (Bollinger Bands) (signal 7)


There are all three types of signals: BUY - the closing price of the previous candle below the lower line, the SELL - the closing price of the previous candle above the top line, "no signal" - the closing price of the candle between the lines.


Indicator Envelopes (signal 8)


Since the appearance and nature of the indicator - the channel signals are similar to the signals in the channel during operation.The BUY - the closing price of the candle below the lower line, SELL - the closing price of the candle above the top line and "no signal" - the closing price between the lines.


Alligator (signal 9)


Also, for all lines use the same method of averaging (AlligatorMethod) and the calculation of the price (AlligatorPrice). A feature of the indicator is that all lines have a positive shift to the right. This allows you to safely read the value of the indicator on the current bar as they are already precisely formed and may not be changed.


BUY signal - lip line above the line of the teeth, and the teeth line up the jaw line, the SELL signal - line the lips below the tooth line and below the line of the teeth of the jaws. In all other cases there is no signal.


Moving Average of Oscillator (OsMA) (Signal 10)


The signals are considered to be a little bit different: BUY - the value of the histogram is above zero, SELL - the value of the histogram is below zero. The state "No Signal" is only in the rare cases when OsMA value will be zero.


Awesome Oscillator (AO) (Signal 11)


It does not options available to the user. One of the principles of work with indicators is to find the "saucers". "Saucer," Bill Williams calls the two increases the value of the bars in the positive area, between which there is a bar with a lower value.Accordingly, the "inverted saucer" - it reduces the value of two bars in the negative area, between which there is a bar with a large value. Thus, to identify the "saucers' require three last generated candles (code - four). BUY signal - "saucer", the SELL signal - "inverted saucer", "no signal" - all the other cases.



Examples of the use of functions


1. The parameter receiving the signal bar

A detailed article on the signal bars



shift (0,1,2 .....) Bar Room

This option is the bar number where your lights will take the signal. When ordering an expert you need to specify such parameters determine the signal: Open the transaction immediately after the signal, or wait for the signal to be generated at the closed bar and open the transaction only to the opening of the next bar

Some indicators, because of their algorithms, have a clear definition: what signal is sent to the bar. If we talk about the clarity and proper execution of the order: the transaction must be processed only at a closed bar that parameter shift = 1, if it is necessary to open the transaction immediately upon the occurrence of a signal on the current bar and the indicator allows it is necessary to set shift = 0.

2. Flip signals strategy



ReverseSignal (true - false) On \ Off

This parameter is an indicator of your revolution \ indicator signals

If your expert is built on a certain algorithm, or in certain indicator signals, you have the opportunity, without reprogramming swap signals BUY \ SELL

For example: ReverseSignal = true

Your light sends a signal to BUY, but the expert opens a deal SELL.

Your light sends a signal to SELL, but the expert open transaction BUY.

3. The use of pending orders at the opening position, instead



StopOrderUSE (true - false) and StopOrderDeltaifUSE (from the minimum stop on the server) in points

This parameter in conjunction is not possible to open positions and pending orders. If we assume after the signal you want to check it by setting a pending order

For example: StopOrderUSE = true StopOrderDeltaifUSE = 100

If your indicator signaled to open a BUY the Adviser open a pending order at the price BUYSTOP Ask + StopOrderDeltaifUSE items

If your indicator signaled the opening of the SELL Adviser open a pending order at the price SELLSTOP Bid-StopOrderDeltaifUSE items

If the parameter is less than the minimum on the server - an expert will give an error 130

4. Magic number



Magic (0 .... 99999) Number

This parameter is a special expert number, which is on the chart, if you use a lot of experts on different schedules, to avoid problems with entanglement between a transaction experts, each expert you need to assign a separate number.

If, for example, you use 1 expert but with different settings, you need to each individual expert settings assigned a magic number. Also, this option should be changed on different currency pairs, in order to quickly deal with the detailed report, which the expert in a pair was tied.

5. Stop-loss transactions



StopLoss (0 ...) in points

This parameter is a Stoploss each position This is the number of minus points, at which the deal will be closed by the server

0 - disabled, and Stop-loss transactions will be equal to 0.

This parameter is necessary to put at least - the minimum stop on your server.

If the parameter is less than the minimum on the server - an expert will give an error 130

6. Take Profit transaction



TakeProfit (0 ...) in points

This option is takeprofit each position This is the number of plus points at which the deal will be closed by the server

0 - disabled, and take profit of the transaction is equal to 0.

This parameter is necessary to put at least - the minimum stop on your server.

If the parameter is less than the minimum on the server - an expert will give an error 130

7. Slippage deals



Slippage (0 ....) in points

This adjusts slippage when opening deal

In the real market price moves very quickly, so when submitting an order to the server, the server can give the answer: Prices have changed, re-quotes and so on. In order not to send the server a lot of orders, you can set the parameters of permissible slippage at opening transaction

For example: Slippage = 10

When submitting orders at the opening price was 1.1234, but the price has changed to 1.1238, in which case the transaction will be opened at the price of 1.1238 is not returning the requotes !. But if Slippage = 0, the transaction will not be opened in this example, the server returns an error requotes (new rates).

8. MARKET execution position on the bill



MarketWatch (true - false)

This option can be enabled for the accounts in the group consisting ECN \ NDD and \ or accounts that use Market execution.

Principle: In the accounts of the group of ECN \ NDD and \ or accounts that use Market execution is forbidden to open positions with established Stoploss \ Take Profit, but is allowed to open a position with a Stop Loss \ TakeProfit = 0, and at the same time after the successful opening of the modified position Stoploss on and \ or Take Profit

This feature, when turned on, first open position, then sets at her Stoploss \ takeprofit

9. Closing of the transaction on the reverse signal



ClosePosifChange (true - false)

This parameter controls the ability to close the deal with the opposite opening of the new. If your indicator uses signals: BUY - SELL - BUY - SELL, then when you turn on this option, an expert before the opening of the new deal will close the opposite



10. The number of position signals strategy



ONlyOnePosbySignal (true - false) On \ Off

This parameter adjusts the possibility of opening one position or multiple positions.

With that in the closed position, each time the signal at 1 bar 1 position will be opened.

For example: your strategy signals given alternately to the BUY signal on each new bar, at the same time if the function ONlyOnePosbySignal = false then the signal is received at each bar will be open transaction BUY

If this function is ONlyOnePosbySignal = true, the expert can open only one deal per deal BUY and SELL and wait until they are closed

New parameter OnePosPerDirection : 1 Opening of the transaction on 1 line

eg:

if OnePosPerDirection = true and ONlyOnePosbySignal = false

then the advisor can open 1 deal Bai on the signal and 1 signal for the deal Cell

if OnePosPerDirection = false and ONlyOnePosbySignal = true

then the advisor can open only one transaction at a signal or Bai or CELL

if OnePosPerDirection = false and ONlyOnePosbySignal = false

then the advisor can open any transaction for each signal indicators



New parameter OnlyOnePositionPerMagic : 1 Opening of the position in 1 Magick,

Advisor to check whether there are open positions on the magic number of other currency pairs. If the position is not present - Advisor to open the transaction on the signal, and the remaining advisers will wait for the completion of this transaction.

 

11. Fixed Lot



Lots (0.01 .........) Setting a fixed bid for all transactions

This sets the number of lots at the opening of the transaction. Lot fixed and apply to all transactions

In this case, you should check with the broker minimum allowable lot, for the opening of the transaction

12. Dynamic Lot

Full article



DynamicLot (true - false) LotBalancePcnt (as a percentage of the free margin)

These settings adjust the automatic calculation and setting of the lot from the free margin

For details on this parameter, described in the article Avtolot (Calculation of the current balance of the lot)



13. Maximum lot



MaxLot (0.01 ......) Setting the maximum bid on the deal

This parameter governs the maximum lot that can be set to one position. Used with Martin parameters and \ or DynamicLot

If the value of the lot in the calculation will be more than MaxLot final exhibition will be equal MaxLot

For example: If you do not want to open the expert transactions 0.09 lot more items, you can set the MaxLot = 0.09.

 

14. Martingale



Martin (1 ....) in the ratio

This option allows you to use the Martingale principle for its strategy, in which the next transaction for the loss-making will be opening at the rate of Lot * Martin

Moreover, if the parameter is equal to 1, the Martingale is not used.

For example: Lots = 0.01 Martin = 2:

1 transaction BUY (0.01) is closed in the red \ or Stop-loss (in red)

2 deal will open a lot 0.01 * 2 = 0.02

3 if the previous transaction was closed on stop loss, the next deal will open lot 0.04

If the previous transaction was closed in the + or else by Take Profit, the following it will be opened with an initial lot 0.0


15. Expert Working hours



OpenHour (in hours) OpenMinute (in (in minutes)) CloseHour (in hours) CloseMinute (in minutes)

These settings adjust the range of advisor working time, with it currently applies only to the opening of new positions Trallingstop, breakeven will work regardless of the range

For example: You want to be an expert to trade only from 14:00 until 18:35, then options will look like this: OpenHour = 14 OpenMinute = 0 CloseHour = 18 CloseMinute = 35

Transactions will be open only in the range of 14:00 to 18:35, at all other times, the adviser will skip signals your strategy.

SeveralTimeWork = Expert working time by several time , 
Recording format: 
start hour: minute start-hour completion: the completion of a minute, an hour beginning: the beginning of the minute-hour completion: the completion of a minute; 
eg: 
09: 00-10: 00; 12: 00-13: 00; 15: 00-17: 30; 

It means that the EA will operate from 9 am to 10 am and from 12 to 13 hours and from 15 to 17:30 

16. Classic TralingStop



TrailingStopUSE (true - false) IfProfTrail (true - false) TrailingStop (in points) TrailingStep (in points)

These parameters include \ disable automatic tracking by modifying the position of the stop loss in + zone.

TrailingStopUSE - Enables \ disables the function Trallingstop

IfProfTrail - if true Advisor starts modification only since the release of the position to breakeven. if false - tralingstop starts immediately after placing position and pulls it behind price

TrailingStop - distance in points from the current price to the alleged stoploss. This option may not be less than the minimum on your server.

TrailingStep- step modification of the stoploss

For example: Stop Loss will be updated every 50 points TrailingStep TrailingStop at a distance of 100 points from the current price


17 TralingStop on PARABOLIC SAR



TrailingStopSAR (true - false) step and maximum (Options Parabolic SAR)

These options include the ability to modify the stop loss set at Parabolica

In this stop-loss will be updated with each new value of the Parabolic SAR.

Accordingly, the BUY modified when the Parabolic SAR is below the price, the Sell modified when the Parabolic is above the price.



18. The function of closing on the total profit \ loss



These parameters govern the opportunity to close the deal \ transaction of the instrument and magick, reaching one of the parameters

Options

TypeofClose = 1; -Type Closing profit 1 - Dollar -Item 2, 3 -% Equity, 4 -% Balan

CloseProfit = false; -Zakryvat If +

prifitessss = 10; -The Number of units (depending on TypeofClose choice) to close the profit

CloseLoss = false; -zakryvat if -

lossss = -10; -The Number of units (depending on TypeofClose choice) to close loss

For example:

If you want to close a few deals BUY \ SELL when profits on the account of $ 10:

TypeofClose = 1; CloseProfit = true; prifitessss = 10;

If you want to close a few deals BUY \ SELL at a loss in a row of 200 points:

TypeofClose = 2; CloseLoss = true; lossss = 200;

If you want to close a few deals BUY \ SELL at a loss on account of 5% of the deposit, as well as to close several deals BUY \ SELL when profits on account of 10% of the deposit:

TypeofClose = 4; CloseLoss = true; prifitesssslossss = 5; CloseProfit = true; prifitesssslossss = 10;



19. Set the stoploss to breakeven



MovingInWLUSE (true - false) LevelWLoss (in points) LevelProfit (in points)

These parameters are adjusted to include the possibility of modifying the transaction to breakeven as soon as possible

for example

You want to set the stop loss to breakeven when the transaction dial +10 pips:

MovingInWLUSE = true; LevelWLoss = 0; LevelProfit = 10;

You want to set the stop loss in five points when the transaction dial +20 pips:

MovingInWLUSE = true; LevelWLoss = 5; LevelProfit = 20;

When this difference between LevelProfit - LevelWLoss must always be greater than or equal to the minimum on the server foot

 

20. Averaging

UseAverDolivkaOrderinOne - to true number of orders is considered common and topping up and equalization;

AverageUSE - Use averaging the opening of additional orders against the trend;

The Distance - Distance net open positions;

LotsMartin - Increasing the bid for a grid position;

MaxOrdersOpen - Maximum number of elbows 0 - unlimited;


This EA supports averaging function positions. How it works is that when the price goes in the opposite direction from the transaction, and passes a certain distance Distance in points - Advisor opens trades in the same direction as the underlying transaction with the lot of the underlying transaction * LotsMartin . Thus it turns out 2 deals with the overall average transaction TakeProfit (If it is set in the parameters TakeProfit of ).


If enabled treylingstop TrailingStopUSE Advisor will accompany the entire series of transactions as a general treylingstopu.


It is also possible to set the maximum number of bends in a series of parameter MaxOrdersOpen


For example:

= AverageUSE to true the Distance = 100 LotsMartin = 2 MaxOrdersOpen = 3 TakeProfit = 50



21. Topping the trend

Dolivka - Use the discovery of additional orders with the trend;

DistanceDolivka - distance open positions Net topping the trend;

LotsMartinDolivka - Increasing the bid for a grid position;

MaxOrdersOpenDolivka - Maximum number of elbows 0 - unlimited;


Advisor is able to refill with the trend, if the price goes in the direction of position. If the price goes over a set distanceDistanceDolivka in points from the opening price of the position, the adviser will open the same position with a lot osnvnoy position * LotsMartinDolivka . It is also possible to set the maximum amount of top-up position

For example :

DolivkaDolivka = true DistanceDolivka = 100 LotsMartinDolivka = 2 MaxOrdersOpenDolivka = 3 TakeProfit = 500



You can also set the stop-loss, treylingstop, breakeven

22. Limitation of loss and profit for 1 day \ week \ Month


  • Limiting LimitFor - Restriction type day \ week \ month

  • LimitForLosses - for profit limit

  • LimitForProfits- limit loss


This feature is able to disable the advisor job, if the advisor to get a certain profit \ loss in the currency of the deposit of the day \ month \ week. This next job counselor will be the next day \ week \ month

For example the DAY = LimitFor LimitForProfits = 1 Closing of the overall profit = $ 10


23. Virtual foot

• VirtualStops - Hides real foot in position and makes them virtual.

This option makes the actual stop loss, take profit, treylingstop, breakeven and everything connected with

stops to virtual stops. Those. Advisor does not hold stoploss \ takeprofit on the broker server, and

keeps all data in memory.

Once the price crosses the level of virtual stops - Advisor closes the position.

Benefits of virtual stops obvious. You can put even the most minimal takeprofit


or stoploss point t 1. The server does not see your stops, thus can not shoot them down.

But there are drawbacks: The computer should always be turned on. Otherwise, the virtual stoploss not work.

When you close the position - can be requotes, thereby shifting points stops.

24. Ghost of all parameters with the feet, to the lowest possible

level on the server

• SetMinStops - Automatic reduction set

This option allows you to bring your settings stops (stop loss, take profit, distance to

pending orders, treylingstop, breakeven) to the lowest possible level on the server.

Modification levels are each tick.

For example: If you set Stop Loss = 10 points, while the minimum stop on your server = 20 points,

when opening a position - the server returns an error 130 that stops short of the minimum level.

If you enable the option SetMinStops Advisor will automatically lead to the level of your Stop Loss 20

points to avoid any error 130.

25. Rounding set opening prices, stop-loss, take profit

• - RoundingDigits - Rounding opening price and stop loss, take profit - for certain characters;

This option allows you to round prices to open positions up to the last mark (Choose between 1 and 2

sign)

For example: Price place a pending order from the calculation = 1.34567 RoundingDigits = To 1 Digit

Advisor to place a pending order at the price of 1.34560

This option can be useful when trading on the stock exchange, stocks and metals, as

Some brokers require rounding the last mark.



Share it with friends: