Expert Advisor Parameters Guide
Expert Advisor Parameters Guide
Contents
How To Use This Manual.................................................................................................................3
Order Parameters...............................................................................................................................4
Indicator Parameters........................................................................................................................6
Trade Signal Management.............................................................................................................7
Trailingstop Parameters (Stoploss)...........................................................................................8
Trailingstop Parameters (Takeprofit).......................................................................................9
Trading Time Filters.........................................................................................................................10
Order Limits.........................................................................................................................................11
Money Management........................................................................................................................12
Stealth....................................................................................................................................................13
Miscellaneous Parameters...........................................................................................................13
How an EA Identifies the Bars on the Chart. ..................................................................14
Setting bar=0................................................................................................................................14
Frequently Asked Questions.......................................................................................................15
Getting Support.................................................................................................................................16
Order Parameters
The following parameters are used for order processing:
• order_comment – a field custom comment that can be used to label the orders
opened by the EA.
You can specify an order comment to be able to easily identify the orders
opened by the EA on the terminal.
Always set different magic numbers to EAs you attach on the charts. When
two or more expert advisors share the same magic number, it means that
those expert advisors are allowed to modify and close each others' orders!
All orders manually opened are automatically assigned with a magic number
of 0. Any expert advisor assigned with the same magic number is allowed to
modify and close manually opened orders.
• _orderbymarket – (true or false) set this parameter to true when the broker
being used does not accept stop orders at order execution. This means that these
types of brokers will only accept orders with 0 stoploss and 0 takeprofit. The order
can be modified after the order has been successfully opened.
To easily identify whether or not your broker allows setting of stoploss and
takeprofit at order entry, open a new trade window. If the fields for stoploss
and takeprofit are greyed out, then the broker does not allow it. Set
_orderbymarket to true.
Indicator Parameters
The parameters and parameter names for indicators used by an EA may vary depending
on the type of indicator(s) used. However, they can be generally classified according to
the following variables:
If more than one timeframe is used in the logic of an EA, they are usually
designated as tf1, tf2, tf3, etc.
• method – the method used on calculations (some indicators only), e.g. simple,
exponential, smoothed, etc.
• applied_price – the price used on calculations (some indicators only) e.g. open
price, close price, etc.
• enableclose – enables/disables closing of all orders that oppose the current signal
(true or false).
• breakevenat – when the unrealized profit (in pips) of an order meets or exceeds
this amount, the order stoploss will be set to breakeven.
• trailingstop – the effective stoploss value of an order for each trailing done on the
stoploss.
• trailingstop_step – the minimum distance (in pips) for trailing. The distance is
measured from the current available price to the price where the last trailing of the
stoploss was done.
• stoptrailing – when the unrealized profit (in pips) of an order meets or exceeds
this amount, the trailing of the stoploss will be deactivated.
• trailingtp – the effective takeprofit value of an order for each trailing done on the
takeprofit.
• trailingtp_step – the minimum distance (in pips) for trailing. The distance is
measured from the current available price to the price where the last trailing of the
takeprofit was done.
• starthour – represents the hour to activate the EA (in combination with starthour)
Order Limits
The following parameters set limits on the amount and/or types of orders opened by the
EA:
• long_enabled – enables/disables EA from opening long positions (true or false).
• maxorders – the maximum allowable amount of active orders on the chart. The
cap only applies to the orders opened by the EA (according to its magic number).
Money Management
The following are the parameters used for money management:
Stealth
The following parameters are used for implementing virtual stops:
Miscellaneous Parameters
The following are the parameters that are used in situational cases only. More often than
not, they are best left to their default values
It is crucial to understand this so users of expert advisors would be able to identify which
bars are being considered by the EA in its calculations. For example, if we have an EA
using a simple moving average with a period of 14 and bar=1, the EA uses the last
formed bar as the starting bar for calculations, then count 14 bars back to identify the
ending bar for calculations.
Setting bar=0
When you set bar=0, the unformed bar will be considered in indicator calculations. Since
the prices for the unformed bar are not yet final (high, low, close), the indicator outputs
tend to fluctuate on that bar when its applied price is not yet final. Thus, this would cause
the signals to repaint on the current bar. Signals that came while the bar is forming may
not be the same when the bar has finally closed.
The EA executes only a few orders, and misses a lot of signals. What should I first do?
Make sure that the maxorders parameter is not preventing the EA from executing
additional orders. Also, make sure if long_enabled, and short_enabled are both set to
true.
I want the EA to only modify and close orders I manually opened. What should I do?
Set magic=0 and maxorders=0.
Getting Support
In the case of unlisted parameters, or if you encounter issues with the parameters not
discussed in this document and do not know as to how to use them, please contact us at
support@metatraderprogrammer.com.