广告
广告
Configurable Strategy Automator EA
User Guide
© 2015 Runwise Limited (UK). All rights reserved. runwiseFX are trademarks of Runwise Limited (UK)
MetaTrader™ is a trademark of MetaQuotes, Inc.
All other trademarks are the property of their respective owners.
THIS DOCUMENT IS PROVIDED ‘AS IS’ WITHOUT ANY WARRANTY OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,
IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, OR NON-INFRINGEMENT.
THIS DOCUMENT MAY CONTAIN TYPOGRAPHIC ERRORS AND/OR TECHNICAL
INACCURACIES. UPDATES MAY BE MADE TO THIS DOCUMENT AND/OR
ASSOCIATED SOFTWARE AT ANY TIME.
TABLE OF CONTENTS
Document Conventions ..............................................................................1
MANUAL TRADING BUTTONS ...................................................................3
Trade Close including Partial Close .......................................................4
MONEY MANAGEMENT (Risk:/Lot:) ..........................................................4
RULE MODE SELECTION............................................................................4
PERIOD SETTING (Period:).........................................................................5
HIDDEN TAKE PROFIT ................................................................................7
MASTER Tick Box..................................................................................7
Stop Loss Adjustment (SL:)....................................................................7
BROKER STOP LOSS & TAKE PROFIT .....................................................8
HIDDEN PENDING ORDERS .......................................................................8
AUTOMATIC SCALE-IN ON PRICE ......................................................8
5 IMPORTANT CONSIDERATIONS .....................................................................10
Configuration & Tools Pop-up..................................................................11
Capturing Indicator and Object Values ...................................................12
Capturing Custom Indicator Values......................................................13
Tick Box GUI Item ................................................................................15
Text Box GUI Item ................................................................................15
1 INTRODUCTION
This document covers how use the runwiseFX Configurable Strategy Automator EA that is available in the MetaTrader Market Place. The EA allows trading rules to be automated, which are read from a text file as if you wrote them down on a piece of paper. The EA also provides full trade and money management features via a interactive control panel. The EA can also handle multiple accounts, where actions be replicated on multiple instances of MetaTrader for different accounts, on the same computer.
Please ensure that you use the EA on demo account until you have familiarised yourself with its operation, in a variety of trading setups. If you have written your own rules then use strategy tester to test them thoroughly.
Link to the product on the MetaTrader Market Place, including screenshots and video: https://www.mql5.com/en/market/product/9602
Note, the product currently supports the MetaTrader 4 platform.
1.1 Document Conventions
The following icons are used to throughout the document:
Take note – try to remember
Very import to take note of and remember - could cause undesirable results if ignored
Top tip – shortcut or other useful information that can make the system easier to use
Advanced feature/subject – can skip over when you are first learning how to use the system
Technical ‘behind the scenes’ detail that you don’t strictly need to know but maybe interested in
Issue 1.5 Page 1
Runwise Limited (UK)
www.runwisefx.com
Issue 1.5 Page 2
Runwise Limited (UK)
www.runwisefx.com
2 CONTROL PANEL
Status Lines >>
Multi-Timeframe Trend
Indicator & Pips Moved >>
Controls per Direction >>
Rule Mode Selection
Configurable Controls >>
(shown here are the supplied rules)
The control panel provides status, indicator values and GUI controls for interacting with the EA. The main controls are repeated for each direction, i.e. SELL and BUY.
This allows for flexible hedging if your broker supports hedging. Most controls are labelled with the exception of the Mode Selection, which is highlighted above.
The settings are preserved if you close the chart down and re-open. This is achieved using MetaTrader’s global variables.
2.1 MANUAL TRADING BUTTONS
2.1.1 Trade Open
The SELL and BUY buttons can be used to open a trade manually based on the lot size shown in the Lots text box. If no stop loss is set then the button will be colored orange and it will not be possible to open a trade in that direction.
The magic number used for the trade is configured in the EA input properties and is used by the EA to detect that trade relates it and should be managed by the EA.
Once a trade has been opened the corresponding SELL/BUY button is replaced by a
Scale-In and a Close button.
2.1.2 Scale-In
Scale-In allows additional tickets to be opened in the same direction, in order to add to the position. The size of the scale-in ticket is expressed as a percentage of the original trade, e.g. if the original lot size was 1 lot and Scale-In is pressed with 20% then an additional ticket will be opened of 0.2 lot size. To scale-in further then the percentage needs to be increased, i.e. 40% would open another 0.2 lots, in the example, creating a total of 40% extra scale-in.
Obviously, scaling-in adds to the risk relating to the trade if the stop loss is still in the original location.
Issue 1.5 Page 3
Runwise Limited (UK)
www.runwisefx.com
2.1.3 Trade Close including Partial Close
The close button also has a percentage setting associated with it. This is the percentage of the trade to be closed. 100% will completely close the trade and 50% will close half the total trade size, i.e. it will scale-out 50%. Note, the total position will include any scaled-in tickets.
To progressively scale-out of the trade the close percentage will need to be increased, i.e. it is the percentage of the original trade that was opened rather that what is left open.
2.2 MONEY MANAGEMENT (Risk:/Lot:)
The EA will calculate the lot size for you based on the percentage of your account balance (or equity – whichever is lower) you wish to risk. The percentage should be entered in the Risk text box and can also be selected via the pop-up, which is activated by pressing the button. You can also enter a fixed amount of the account currency by simply typing the amount in and omitting the % sign.
The pips at risk that is used for the lot size calculation comes from the current position of the hidden stop loss line (yellow) and the current price.
To manually enter a lot size, simply clear the Risk text box and enter the required lots value into the Lots text box.
2.3 RULE MODE SELECTION
The following modes are available that relate to the level of automation of the EA.
MAN
Manual Mode. This turns off the rule engine for when ticks come in form the market or on regular time intervals. However, rules can still be executed on ‘script basis’, i.e. executed when a user configurable button is pressed, e.g. Close All Trades button of the supplied rules.
EVL
Evaluate Mode. Rules are evaluated on incoming price ticks and regular intervals. However, TRADE_OPEN, SCALE_IN, and
TRADE_CLOSE commands will be ignored, in terms of raising alerts or opening/closing trades. However, the alert lines will still be set on the chart.
Note, if a rule uses the FORCE_CLOSE command then this can still cause the trade to be closed unless in manual mode. Rules should only use this command if there is a tick box placed on the control panel that can be used to turn this behaviour off, or if called upon a user interaction, e.g. button press. We recommend keeping the EA on at least EVL mode, so that the close features of the supplied rules will still work, e.g. Close All Trades button.
Issue 1.5 Page 4
Runwise Limited (UK)
www.runwisefx.com
ALT
TOE
TOA
TOC
Alert Mode. Rules are evaluated and any TRADE_OPEN and
SCALE_IN, TRADE_CLOSE commands will result in an alert but won’t actually open/close trades. Note, the alert will only happen if the alert line hasn’t already appeared. Note, a FORCE_CLOSE issued command issued by a rule will still close the trade.
Trade Once then Evaluate Mode. This will act up on TRADE_OPEN
SCALE_IN and TRADE_CLOSE (and FORCE_CLOSE) commands but after being executed the mode will switch to EVL. This can be used to authorise the EA to do a one-off action, which we refer to as semiautomatic.
Similar TOE but after execution the mode will be switched to ALT.
Trade continuous. This will act up on TRADE_OPEN and, SCALE_IN,
TRADE_CLOSE commands and keep doing so.
It is important that you test your rules well before this mode is selected, which we refer to as automatic.
2.4 PERIOD SETTING (Period:)
This is the default period used by the automatic stop loss and rules engine. If set to 0 then this will the timeframe of the chart that the EA has been placed on.
If set to 0 then any change to the timeframe of the chart the EA is running on will cause the stop loss and rules to be calculated on that new timeframe. This could cause a trade to opened/closed if the direction is different on the new timeframe, assuming mode is set to something that would permit open/close. To avoid this, either be careful changing the timeframe of the chart the EA is running on or select a particular period rather than 0.
2.5 HIDDEN STOP LOSS
The hidden stop loss is shown by a yellow dashed line on the chart, labelled hsl. This label will also indicate the number of pips from current bid price, or open price if a trade is open, and if trailing mode has been enabled. The hidden stop loss is used as the basis for calculating the risk pips, which is in turn is used to calculate the lot size based on the specified risk
The hidden stop loss, pending lines and take profit all work on the bid price. This prevents these items from being triggered by spikes in the ask price, which could come from broker manipulation as the ask price is not shown on the charts or in the history. The bid price is also the price shown by the candles, so it means you do not have to account for the spread when setting lines from what you see on the chart including indicators that are calculated from the candle prices e.g. moving
Issue 1.5 Page 5
Runwise Limited (UK)
www.runwisefx.com
averages.
2.5.1 SL Mode (SL:)
By default the EA will calculate the stop loss automatically (AUTO) by using a built-in professional grade indicator and do so based on the timeframe selected by the
Period: selection list. Other stop loss modes can be selected as follows:
OFF
Turns off stop loss. Can be used to remove unnecessary lines from the chart.
AUTO
RULE
MAN
n Pips
Automatic. Uses our built-in indicator to set the stop loss.
Set by rules. Allows rules to set the stop loss using the
SET_HIDDEN_SL command.
Manual. Allows the stop loss to be set by manually moving the line on the chart.
Simple linear stop loss based on the selected number of pips from the current bid price.
The list of pips from current price can be configured by the Main_selectionSLmodePips EA input property.
2.5.2 Trailing (Trail tick box)
If the Trail tick box is ticked then the stop loss after a trade has been open, depending on the stop loss mode selected.
The trail mode won’t ever set the stop loss to be further away, regardless of settings. Therefore, if you were trailing by 10 pips but then selected 20 pips, you would need to move the stop loss further away manually. This is a safety feature as an increased stop loss could potentially increase risk.
Tailing with AUTO mode is great to capture profit over a number of candles as in automatic mode it gives the trade some breathing room to begin with before the stop loss starts to move. Even then the stop only moves significantly after candle close. However, if you wish to the trailing stop to capture profit of the current live candle or previously closed candle then a set number of pips from bid price would be better, as it works faster.
Issue 1.5 Page 6
Runwise Limited (UK)
www.runwisefx.com
2.6 HIDDEN TAKE PROFIT
The hidden take profit lines are show as cyan dashed lines on the chart, labelled htp.
This label will also indicate the number of pips from current bid price (or open price when trade is open) and the auto risk reward (rr) setting if set.
By default four lines are shown (configurable) that permit the trade to be scaled out.
The hidden take profit settings are contained within a pop-up that is shown when you press the TP button. Use the OK button to make any changes, or Cancel if you change your mind.
The take profit pop-up shows the settings for each of the exit levels.
The EA input properties can be used to change the default values used for the various tick boxes and selection fields. This even includes the number of take profit levels – by default 4 but can be set to a lower number.
2.6.1 MASTER Tick Box
If this is unticked then the hidden stop loss feature will be switched off.
2.6.2 Exit %
If ticked this will perform the partial close of the trade using the percentage of the trade to close shown with the tick box, when the target price is reached. If 100% is selected then this will close the entire trade. If 0 or the box is unticked then no close will take place.
2.6.3 Auto Ratio
If ticked then the take profit target is set automatically based on the risk reward specified next to the tick box. If unticked then the target can be set manually by moving the line on the chart.
2.6.4 Stop Loss Adjustment (SL:)
If set then will adjust the stop loss when the profit target is reached. This can be in terms of raising the stop loss and/or setting stop loss trail mode on. Raising the stop loss means when the first take profit is reached the stop loss is raised to breakeven and when the second take profit line is reached the stop loss is raised to what the first take profit target was set to, and so on. The trail will set the Trail tick box for the trade.
Issue 1.5 Page 7
Runwise Limited (UK)
www.runwisefx.com
If you just want to set the stop loss to trail (or raise) when a certain price is reached but not partially close then simply set the exit % to 0 or untick the check box next to the exit percent and set the SL accordingly, i.e. take profit line is still active even if no exit % is set.
However, if MASTER tick box is unticked then this will turn this feature off.
2.7 BROKER STOP LOSS & TAKE PROFIT
The EA will also set the broker stop loss and take profit, but further away than the hidden settings. In the case of take profit, it is the take profit line that is set to exit
100% of the trade that is used. The extra distance from hidden should make it less tempting/able for the broker to deliberately hit your stop loss or avoid your take profit.
2.8 HIDDEN PENDING ORDERS
In addition to hidden stop loss and take profit, the EA also supports hidden pending orders. The reason for using hidden pending orders is so that broker isn’t tempted to nudge the price/spread to trigger your broker pending order when they believe the market isn’t favourable.
To set a hidden pending order, simply tick the hidden pending buy and/or sell checkboxes. This will show the pending line on the chart that can then be moved to the desired price. The mode will automatically change between Limit and Stop depending which side of the current price you place the line.
The EA can either open a trade or alert when the target price is reached. This is controlled by toggling the ALERT/TRADE toggle box that is shown next to pending checkboxes. There are also options to trigger when the price has closed above/below the pending price.
2.8.1 AUTOMATIC SCALE-IN ON PRICE
The EA can be set to automatically scale-in when a target priced is reached. To use this feature tick the corresponding Pending checkbox for the direction that the trade is open for. This will be place a ‘pending scale-in’ line on the chart that can be positioned to the desired price. When that price is reached the EA will either alert or perform the scale-in, depending on the ALERT/TRADE toggle box setting. The scalein in percentage is that which is shown next to the manual Scale-In button.
Essentially, in auto mode the EA presses the Scale-In button for you.
It is best to leave the ALERT/TRDE toggle box set to ALERT whilst you position the line, just in case the market moves and touches the default price where the line is placed. When you are happy with the line position you can the switch to TRADE.
Issue 1.5 Page 8
Runwise Limited (UK)
www.runwisefx.com
2.9 BREAKEVEN
The ‘Breakeven’ checkbox can be used to set a trade for breakeven where the trade will be exited when the price comes back to its open price. If you change your mind whilst the trade is still open, simply untick the breakeven checkbox.
3 BUILT-IN INDICATORS
The EA is supplied with several professional grade indicators that are built into the
EA. The first is shown within the control panel that gives the direction the market is moving in, on multiple timeframes. A solid arrow is where there has been a reversal and a hollow arrow is where it’s just currently a retracement. The number next to the arrow is the pips moved in that direction and can used to know how much of the move has been missed. Note, the timeframes shown can be configured via the input property Main_indiDirPeriods.
On the chart, the daily, weekly and monthly pivots are shown and the daily support and resistance lines (S1-3 and R1-3). These lines are useful as it can be the price at which a move may stop and not break through, i.e. pivot fail/bounce.
The average daily range is shown in the top left of the chart, together the percentage of that range that the symbol has already done. If that percentage is approaching
100% or exceed 100% that it can be an indication that the symbol may not move much more in the current trading day.
Finally, the current spread is shown top right, color coded if spread is high. The current ask/bid prices are show bottom left in large text. Again color coded if the price is going up, down or the same (yellow). Both of these indicators can be turned off.
4 SUPPLIED RULES
The EA is supplied with rules that permit trades to be opened or closed when the trend changes direction on the control panel set period. This is achieved by using the built-in indicator shown by the trend direction arrows. Note, the period does need to be shown by the arrows, i.e. in Main_indiDirPeriods. The Trend Change Exit tick box needs to be ticked for the exit to work, but it does use the FORCE_CLOSE command, so can close trades while in evaluate or alert mode. If the Inc.
Retracement tick box is ticked then the rules to work when just a retracement has been signalled, i.e. a hollow arrow shown.
The Auto Breakeven tick box allows breakeven to be set automatically on an open trade when a profit target is reached. The input properties RWFX_BkEven* can be
The Close All Trades button will signal to this instance and other instances of the EA on other symbols to close all trades that the EAs are managing, i.e. trades with the magic number that is set for the EA. The FORCE_CLOSE command is again used, so will work if the EA is above manual mode.
Issue 1.5 Page 9
Runwise Limited (UK)
www.runwisefx.com
5 IMPORTANT CONSIDERATIONS
The EA must remain on the chart of the symbol for which a trade has been opened. Otherwise, the hidden items, including breakeven and auto exit will fail to work.
Your internet connect and login status with your broker must remain in place for the hidden items, including breakeven and auto exit to work.
The broker stop loss and take profit will be the fallback if this fails.
A smiley face is shown in the top right of the EA’s control panel that indicates that the EA is allowed and is able to trade (including being able to a close trade (say) when a hidden stop loss is hit ). If a straight face is shown then it means another chart is open for the symbol that has the EA running and that EA is regarded as the one that is managing trades for that symbol. Note, if you closed that other chart then the should change to .
If you see a sad face then check trading allowed/login and internet status, as the EA believes it is unable to trade and the hidden items including auto exit and breakeven will not work.
Issue 1.5 Page 10
Runwise Limited (UK)
www.runwisefx.com
6 STRATEGY AUTOMATION
A big part of the EA is that it can be configured with your trading rules than can alert, open/close trades, adjust stop loss and more, based on indicator/chart object values and other information from MetaTrader. The rules can also be interactive with extra control panel items, such as tick boxes, input boxes, buttons, etc. that the rules can act upon.
Remember we are here to help! This part of the system can seem a bit daunting and there is a learning curve. However, feel free to contact us if you are suck / don’t understand: [email protected]
6.1 Configuration & Tools Pop-up
The configuration is done via a text file that can be created via the pop-up shown when the CONIG button is pressed:
The Configuration Filename shows the current configuration file in use by the EA.
The default is the runwiseFX_CSA_Supplied.txt.
Issue 1.5 Page 11
Runwise Limited (UK)
www.runwisefx.com
The location of the configuration file can be found by clicking the File |
Open Data Folder menu option on MetaTrader. Then select the
MQL4\files folder if running the EA on a normal chart. If using the EA in the strategy tester then the file is located in the tester\files folder.
Therefore, if you are strategy testing a configuration file then it will need to be copied the MQL4\files folder before is can be used on a regular chart.
The pop-up is populated with how many of each of type of items are defined in the file. You can increase the number and then press the Amend button to add new items to the file. The configuration text file can then be edited to fill in the details about the item. Any comments can be inserted start with a single quote. You can use a standard text editor, such as Notepad, to edit the file. However, we recommend
Notepad++( https://notepad-plus-plus.org/ ) as this will give you line numbers and any errors in your file will be reported by line number.
The Reset button can be used to clear the form so that details of a new configuration file can be entered. Using separate configuration files allows you work on a new strategy without interfering with the current one.
The Test button will do a syntax check of the specified configuration file and report any errors in the file. Errors will be alerted and also reported in the Experts tab.
Remember on the strategy tester the alerts go in the Journal tab.
The Use as Default button will instruct the EA to use the specified configuration file from now one, including when the EA is restarted. Note, this can be overridden by setting the file Main_configFileName EA input property.
The current strategy file that is being used by the EA is set in a file called runwiseFX_CSA_Cfg_Settings.txt. Pressing the Use as
Default button will update this file to point to the new configuration file.
The tools part of the pop-up allows you to print indicator values that are being captured based on the configuration and also the outcome of the rule evaluation.
This output appears in the Experts tab.
6.2 Capturing Indicator and Object Values
The first aspect of automating a strategy is to capture the required indicator values.
These can be from custom indicators installed on your MetaTrader installation, or built in MetaTrader functions for standard indicators, such as moving averages, stochastic, CCI, RSI, etc. It is also possible to capture values from objects that indicators place on the chart, i.e. listed in Charts | Objects pop-up on MetaTrader.
Begin by decided how many values you would like to capture and putting number in the No. of Indicator Values text box of the Configuration pop-up. The click
Create/Amend button that will then put template items into the configuration file,
which you should then open in a text editor to fill-out the details see 6.1 for details on
where the file is located.
Issue 1.5 Page 12
Runwise Limited (UK)
www.runwisefx.com
6.2.1 Capturing Custom Indicator Values
Example configuration file entry to capture the red line of the TDI (Traders Dynamic
Index) indicator for the live candle and current chart timeframe:
[indi.TDIred] indicatorNameOnMetaTrader=TDI colorIndex=5 period=0 shift=0 inputProperties= interpretationMethod=A interpretationParameters= digits=1 nullValue=AUTO
Meaning of each of the lines:
be stored in and can be referred to in the rules, e.g.
i.TDIred would could be used in the rules to refer the
TDI red value. If you are capturing the same indicator value but on multiple timeframes or multiple shift (e.g. live candle and candle just closed) then add this to the indicator name, e.g. TDIredM5 and TDIredH4 could be used for the indicator values from the 5 minute and 4 hour timeframes, respectively. Note, the
[] brackets indicates that this a item/section header with details below. indicatorNameOnMetaTrader This is name used within MetaTrader, i.e. appear in
Navigator panel in MetaTrader. The .ex4 extension can be included or not. colorIndex period
Index 0-7 that the value comes from and can be determined by viewing the Color tab of the indicator properties on MetaTrader. The indexes are show under the # column with the corresponding color that that index represents when the indicator is shown on the chart. In our example, index 5 is used for the red line of the TDI, which is what we are interested in.
Period of the timeframe to capture, where 0 is the timeframe that the EA is running on. Else, a particular timeframe can be specified, e.g. M15.
Take care with period 0 because if the timeframe is changed on the chart the EA is running on then suddenly in all likelihood the indicator will be returning a different value as it is now from a timeframe.
Issue 1.5 Page 13
Runwise Limited (UK)
www.runwisefx.com
shift inputProperties interpretationMethod digits nullValue
Shift 0 is the live candle and shift 1 is the candle m ost recently closed, and so on. For indicators that project into the future, then negative values ca n be used.
Indicator input properties, i.e. inputs that can be specified when the indicator is place on the chart . If empty then the indicators default properties will be used. Note, the properties must appear in the sa me order and any true/false parameters should be convert to 1/0, respectively. Note, due to a limitation of MetaTrader and string input will have to give a numerical value.
A = as-is, i.e. just return the indicator value as shown on the chart. B = boolean where 1 is returned if the indicator value in not the nullValue and 0 if it is. D = distance (number of bars) to arrow/star/dot, i.e. number of candles to where the indicator value is not the nullValue.
Number of digits after the decimal point when storing and printing the value. If set to AUTO then will use the number of digits shown for the price on the chart.
The value of the indicator that represents null (not shown on chart), if it is has one. This is used for interpretationMethod B. AUTO will check for
EMPTY_VALUE, -1 or 0. Also can be just set
EMPTY_VALUE. Note, EMPTY_VALUE is the official
MetaTrader value that an indicator should use to symbolise a null value. However, many indicators do use 0 and some -1.
6.3 Control Panel GUI Items
The configuration can contain additional GUI items that are to appear on the control panel, i.e. labels, tick boxes, text boxes and buttons. The current value of the items can be referred to into the rules, so that the rule can be interacted with. The labels can be used by the rules to show information on the control panel. Further, rules can triggered on the click of the GUI item, e.g. button press, these are called GUI rules and provide a script like behaviour, e.g. close all trades.
The different types of GUI items are configured as follows:
6.3.1 Label GUI Item
[gui .label.<labelName>] defaultValue=<value to color=<color of label> appear on the label>
The <labelName> is name that can used in the rules to refer to the GUI item and should be unique and meaningful, e.g. totalProfit. The defaultValue is what the label
Issue 1.5 Page 14
Runwise Limited (UK)
www.runwisefx.com
text should be in itially, but can b e changed by the rules. color is the initial color o f the label, bus also can be changed by the rules. If left blank then the default will be color used.
6.3.2 Tick Box GUI Ite m
[gui.tickBox.<tickBoxNa caption=<text to appear me>]
next to the tick box> defaultValue=<1 for the box to ticked by default, else 0 >
The <tickBoxName> is name t hat can used in the rules to refer to the GUI item and should be unique and meaning ful, e.g. trendExitOn. Example:
[gui.tickBox.trendExitO
caption=Trend Exit defaultValue=0 n]
Create s a tick box with the capt ion ‘Trend Exit’, which is not ticked by default. The tick box can be referred to in th e rules by g.trendExitOn and will have the value 1 i f ticked else 0 if not ticked.
6.3.3 Text Box GUI Ite m
[gui.textBox.<textBoxNa caption=<text to appear defaultValue=<default t me>]
next to the text box> ext to place in the text box>
The <textBoxName> is name t hat can used in the rules to refer to the GUI item and should be unique and meaning ful, e.g. pipTarget. Example:
[ c gui.textBox.pipTarget] aption=Pips Target defaultValue=40
Creates a text box with the caption ‘Pips Target’ with the default value of 50. The text box can be referred to in the rules by g.pipTarget and will have the value of the text contained in the box.
6.3.4 Button GUI Item
[gui.button.<buttonName>] defaultValue=<text to appear on the button >
The <buttonName> is name that can used in the rules to re be unique and meaningful, e.g.
fer to button and should
closeInProfitTrades. Example:
[gui.button.closeInProfit
Trades] defaultValue=Close In Profit Trades
Creates button with the text ‘Close In Profit Trades’.
Note, to add a rule that is executed when the button is pressed, the button name should be used in the rule header, for example:
[rule .gui.closeInProfitTrades]
,t.profit,>,0,TRADE_CLOSE
Issue 1.5 Page 15
Runwise Limited (UK)
www.runwisefx.com
6.4 Specifying Rules
Rule are specified by the [rule.*] section header and a series of lines. Each of the lines has several comma separated fields. The format is:
[rule.<entry|exit|gui>.ruleName]
<flags>,<operand1>,<operator> ,<operand2>,<commands>,<failComment>
For example, an entry rule for the popular TDI indicator (Traders Dynamic Index) might be:
[rule.entry.TDIentry]
N,i.tdiGreen,/>,50,A ND,”green n ot crossed 50”
N,i.tdiRed,/>,i.tdiYellow,TRADE_OPEN,”red not crossed yellow”
This wi ll op en a trade on the open o f a new bar (signified by t he flag N) when the TDI green line has crossed 50 and the TDI red line has crossed the TDI yellow line. Note, the ‘/’ next to the greater than sign ‘>’, is used to indicate that the ‘>’ should be flipp ed to a ‘<’ when evaluating the rule for a sell. The optional fail comment is u sed to show on the status whether it is the green or red line that is being waited for.
Other rules types available are exit that are evaluated when trade open and gui rule, for which an example was given i n the previous section.
Here is an example exit rule , again using the TDI indicator:
[rule.exit.TDIexit]
,i.tdiGreen,/<,50,TRADE_CLOSE,”green okay”
This will close the trad e when the TDI green crosses back over 50. This the rule doesn’t just operate on the open of n ew bar, but is evaluated on every tick. The optional fail comment will write on the status “green okay” if rule is active but green not yet crossed 50.
GUI rules are evaluated on the click of a GUI item, e.g. button. Entry rules are evaluated on incoming ticks from the market and at regular intervals. Exit rules are evaluated when a trade is open. Entry rules are still evaluated even when a trade is open in case a scale-in is required via the SCALE_IN command. H owever, any TRADE_OPEN commands are ignored once a trad e is open for the direction.
GUI rules and entry rules are evaluated in both directions (sell and buy). Hence, any TRADE_OPEN commands will open a trade in the direction that is being evaluated and for which the rules match.
Issue 1.5 Page 16
Runwise Limited (UK)
www.runwisefx.com
Although entry and exit rules are evaluated on regular timer ticks
(currently every 1/3 of second) as we ll as market ticks, any trade open/scale-in/close commands will be ignored unless it is a tick from the market. This prevents the rules from tryi ng to open/close a trade when the market is closed, which would result in repeated errors.
The <flags> can be empty or one of N,B,S,$,%. N means evaluate line on a newly opened ba r (candle). B means evaluate line when evaluating for buy, otherwise ignore the line. S means evaluate the line when evaluating for a sell, otherwise ignore the line. $ means evalua te as a string (text). % means evaluate as an integer
(whole number), i.e. any floating point numbers will be rounded up.
The <operator> can be one of =,<>,<,>,>=,<=,contains,notcontain. The contains operator will look of operand 1 inside of another operand 2 and match if is there. The
notcontain will match if the operand cannot be found inside operand 2. As mentioned in the examples, a ‘/’ can precede the operator that will invert the operator when evaluating for a sell. This can avoid the need for separate lines with B and S flags.
A variety of operands can be used. Please contact us with your requirements.
A variety of commands are available, see 6.4.1. <command> can also be AND which means the following line(s) must match also, or OR w hich means either this line or the next one or one after if OR is still specified. Multiple commands can be specified separated by ‘|’ (ve rtical bar). If a command is preceded by a ‘!’ then the command is only executed if the expression does not matc h.
The <failComment> is optional and is displayed in the status lines on the control panel if rule fails to match on the line. It can be used to know why the rule is not performing the action associated with it. Note, if the comment contains a comma the n don’t forget to includ e double quotes around the text, or you may just wish to enclose double quotes around the fail comment for clarity.
Rules can have multiple lines that end in a command(s). However, the
END_EVAL command can be used to stop the evaluation of the particular rule, regardless of what follows.
If any fields on rule logic line contain a ‘,’ (comma) then place double quotes around the field so that the parser doesn’t get confused, as commas are also used to delimitate fields.
6 .4.1 Commands
The following commands can be used in rules and appear as the 4 th
field on the logic line of a rule. Remember multiple commands can be separated by ‘|’ and if a command is preceded by ‘!’ then it is only executed if the expression before it does not match.
Issue 1.5 Page 17
Runwise Limited (UK)
www.runwisefx.com
Parameters c an use single quotes for strings. Parameters can also reference operands by e nclosing them inside curly brackets {}. E.g.:
ALERT(‘TDI
This would ra
yellow is now {i.tdiYellow}’)
ise an alert and text would include the value of tdiYellow indicator.
DESCRIPTION COMMAND &
PARAMETERS
ALERT(<msg>) Will issue an alert with the text supplied in <msg>. Note, th e alert will be push notified / emailed if the EA has been configure d to do this. You must have logic in the rule to prevent repeated alerts t hat are not desired.
ALERT_LOCAL(<msg) Similar to alert. However, we only be shown in the alert pop-up and not push notified or emailed, even if the EA has been configure d to that.
AND Not strictly a command but is used to join logic lines together. AND means the line and lines above must match the following line s (see OR as well).
CLEAR_BREAKEVEN Will clear the breakeven tick box on the EA control panel for the direction being evaluated (see SET_BREAKEVEN).
END_EVAL(
<failComment>)
Will stop the rule from being evaluated any further. An optional
<failComment> will be shown on the status on the EA con trol panel, which is intended to indicate why the rule is not being ev aluated any further.
FORCE_CL
<prct>)
OSE( Will close any open trade with the specified percentage of the trade to close. If <prct> is not specified then the entire trade will c losed, including any scale-in tickets. The command will as lon g as the EA is not set to manual mode for the direction (see TRADE_CLOS E that only has an effect if the EA is in alert/trade mode for the direction ).
Will set GUI control panel text label item with supplied text and optional color and font size.
GUI_SET_LABEL(
<name>;<text >;
<color>;<size >)
MESSAGE_CONFIRM(
< msg>)
Will pop-up a message dialog box showing the supplied <msg>. If the
Cancel button is pressed then the rule will not be evaluated any further. Useful for confirming actions, e.g. button press, with the user.
Must only be used in GUI rules, as thes e are only executed on use r click, i.e. when user is present. If the dialog bo x is not answered then the EA will be unable to process any f urther, including hidden stop loss, etc.
OR Not strictly a command but is used to join logic lines togethe r. OR means the current line or other lines above or below that als o have
OR, must match (see AND as well).
Issue 1.5 Page 18
Runwise Limited (UK)
www.runwisefx.com
PLAY_SOUND(
<wavFileName>)
PRINT(<msg>)
SCA LE_IN(<prct>)
SCREENSHOT
SEND_MAIL(
<subje ct>;<msg>)
OBJ_CREATE(
<name>;<type>)
OBJ_SET(<name>
<propert
<value>)
; yIDValue>;
OBJ_SET_COLOR(
<name>;<color>;
<style>)
OBJ_SET_FONT(
<name>;<fontSize>;
<fontName>)
Will play wav file located in Sounds folder of Data Fo lder. If no parameter is specified then any p laying sound will be stopped.
Will print, i.e. write, supplied message to log.
Will perform scale-in by eith er supplied <prct >, i.e. percentage of original trade – what has already been scaled in. Or, if <prct> is not specified then will scale-in based on corresponding setting on EA control panel.
Will take screenshot of current chart that the EA is running on and place in t he File folder of the Data Folder. Screen shot files are name rwfx_ss_* and can be controlled by Gen_screenShot* input properties.
Will email (if MetaTrader has been configured to do this) with the supplied subject and message.
Will creat e chart object of specified name and type. If <name> starts with ‘*’ then the runwiseFX application ID will be inserted that allows the object to automatically deleted if the EA is removed from the chart.
Note, initially objects are created with a location so th ey cannot be seen. TIP: Rule of type initGui can be used to create objects before the
EA control panel is created, so they appear behind the control p anel.
<type> = object type OBJ_* with the OBJ_ omitted, e.g. HLINE will create a horizontal line object. A full list of object types can be found a t: http://do cs.mql4.com/constants/objectconstants/enum_object
Will set object property to have supplied numerical value. The
<propertyIDValue> is the second column of the table show here: http://docs.mql4.com/constants/objectconstants/enum_object_property .
Note, other OBJ_SET_* commands are available that make it easier to set certain properties and are also required for text based prop erties.
Will set object color and optionally style. <color> can be RGB comma separated or one of web –color constants, e.g. clrMagenta, see: http://docs.mql4.com/constants/objectconstants/webcolors .
Don’t forget if using commas in commands then will need to enclose the entire command field, of the logic lin e, in double quotes, as commas are also used to delimit each of the fields in the logic line.
For <style> see http://book.mql4.com/appendix/styles for available styles, e.g. 0 = solid, 1 = dashed, etc.
Will set object font size and font name. If either parameter is blank (or in the case <fontName> not supplied) then no change will be made to that property.
Issue 1.5 Page 19
Runwise Limited (UK)
www.runwisefx.com
OBJ_SET_POSITION(
<name>;<x>;<y>;
<corner>)
Will set position of the object on the chart with supplied X and Y co ordinates and corner settings. Corner can be one of LU (left upper), LL
(left lower), RL (right lower), RU (righ t upper). Note, if any parameter is blank then it will not be set, also <corner> may be omitted.
OBJ_ SET_PT(
<name>;
<price1>;<time1 >;
<price2>;<time2>;…)
OBJ_SET_TEXT(
<name>;<text>;
<color>)
SET_VAR(<name>;
<value>;<symbol>;
<temp>)
SEND_NOTIF(<msg>)
SET_BREAKEVEN
Will set object price and time. This can be used for objects that are placed on the chart at a particular time and price. Note, <price2> and
<time2> are optional. <time1> can also be om for horizontal line. If <price1> is blank but <time1> is set then just
TIME1 will be set, e.g. for vertical lines. itted just to set price, e.g.
Will set the text property of the object with the supplied text and optional color ( see OBJ_SET_COLOR for more details about setting object colors)
Will set a global variable of supplied name and value. Note, value has to be a number. Optional <symbol> can also be specified to s specific sym et of a bol, which if ‘*’ will cause the variable for all symbols to be set. If the optional <temp> is set as TEMP then the global variable will be marked as temporary, i.e. not preserved between closedown/re start of MetaTrader.
Will send push notification email (if MetaTrader has been configured t o do this) with the supplied message.
SET_PEND(<price>;
<action>)
Will set the breakeven tick box on the EA control panel for the direction being evaluated. This command should only be issued when a trade is open and in profit – if not in profit then would immediately exit the tra de
(see CLEAR_BREAKEVEN).
Set pending line for the direction being evaluated, including setting type and mode. <action> is one of ALT or TRD. Note, the limit/ stop type will be set depending on where the line is placed in relation to the price. However, if the trade is open then the type will be set to scale-in, provided the price is appropriate for a scale-ion, e.g. if buy then price needs to be above current price. The <action> can be omitted to leave as is.
SET_PEND_PRIC
<price>)
E(
TRADE_CLOSE(
<prct>)
TRADE_OPEN(
<riskAdjustPrct>)
Set the pen the price wi ding line price for the direction being evaluated. However, ll not be updated if it ca uses the pending line to jump over current price , e.g. from Limit to Stop type, i.e. is only intended to update the price not the type (Limit/Stop).
Will close any open trade (or alert if alert mode is set) with the specified percentage of the trade to close, if the mode is set to trade . If
<prct> is not specified then the entire trade will closed, including any scale-in tickets. See FORCE_CLOSE that will work regardless of m ode setting unless the mode is manual.
Will open a trade in the direction that is being evaluated using the settings on the EA control panel, provided mode is set to trade. Will alert if mode is set to alert. If a trade is already open then no action will
Issue 1.5 Page 20
Runwise Limited (UK)
www.runwisefx.com
be taken. Note, if you want to open additional tickets then use the
SCALE_IN command. The optional <riskAdjust> can be used to adjust the risk that has been specified on the EA control panel, e.g. if risk is
3% of account but this parameter is 10, i.e. 10%, then the risk used will be 3.3%. Negative values can be used to reduce risk. This paramete r allows rules to adjust risk based the probability of the trade being successful.
7 MUTLI -AC COUNTS
Multiple instances of the E A on different accounts, i.e. on different instances of
MetaTrader, can talk to each other p rovided they are on the same comput er. This can enable actions on one account to be automatically replicated on the other accounts, using a m aster/ slave principle. This works better than a trade copier as trades can be op ened/clo sed at the same time, where as a trade copier needs to see the trade op ened on one account bef ore it can be opened on the other and similar for close. This creates an inh erent delay and the potential for slippage between accounts.
To active multi acco unt su pport set the Main_multiAccountMode input property of the EA to Master on the a ccount you want to the be master (a M should appear above the CONFIG button ) and set Main_multiAccountMode to slave on the other accounts (a S should appear). Actio ns performed on the master account should be
You can test the link via the CONFIG button and t hen click Test Alert to Slaves button on the Configuration & Tools popup.
It is possibl e to share the same configuration file across multiple instances of MetaTrader on the same com puter. To do this set
Main_c
onf
igFileName EA input property to the configuration filename and set
Ma
in_configInCommonFolder input property to true. The configuratio n file should be placed in the common data folder. The common da ta folder can be found by going to the Tools | MetaQuotes
Language
Editor and then in that tool clicking on to File | Open
Common D
ata Folder menu.
8 E A INPUT PROPERTIES
Any change s to the EA input properties can be applied to other charts by saving a template within MetaTrader. Please consult the
Meta Trader help files on this.
Issue 1.5 Page 21
Runwise Limited (UK)
www.runwisefx.com
Variable
Important_defaultStopLossMode
Important_defaultStopLossTrail
Important_magicNumberT oUse
Important_lots
Important_riskAmount
Important_tpRiskRewardRatios
Description
Default stop loss mode
Default setting for the stop loss trail tick box
Magic number for trades that the EA opens. The
EA will ignore trades with a different magic number.
Lot size to be used if risAmount is not set
(blank). If this input is set the
Impo rtant_riskAmount should not be, i.e. be blan k. The value can still be changed on the control panel.
Risk amount to be used. Can be % of account/equity (whichever is smaller ) or fixed amount (omit percentage). The value ca n still be changed on the control panel.
Take profit risk reward ratios (comma separated) for each level.
Important_tpExitPrcts
Important_tpA djustSLasTargetsReached
Main_alert*
M ain_averageDailyRangeDays
Main_averageRangeCorner
Take profit exit percentages (comma se parated) for each level
Take profit stop loss adjust on target s etting
(comma separated) for each level. 0 = no action, 1 = raise SL, 2 = trail SL, 3 = raise & trail
SL
Additional pixels to add between control panel
GUI items. Useful if system font sizing a bove normal is being used.
Allows various alerts to be turned on an d off
Days used for ADR cacluation. Recommend leaving as is.
Chart corner where ADR is displayed
Issue 1.5 Page 22
Runwise Limited (UK)
www.runwisefx.com
Variable
Main_average RangeMode
Main_avera eRangeX
Main_averageRangeY
Main_averageTrueRangeDays
Description
Switch from ADR to ATR (Average True Range)
X location of ADR
Y location of ADR
Days used for ATR calculation. Recommend leaving as is.
Main_breakevenThresholdPips
Pip profit below which breakeven close will occur (if set)
Main_brokerSLTPAdjustmentThresholdPips
Pips difference between calculated broker
SL/TP and actual for modification to happen
Main_brokerStopLossExtraPips
Main_confirm*
Main_configFileName
Main_configInCommonFolder
Main_brokerStopLossMoveWithHidden
Main_brokerTakeProfitExtraPips
Main_brokerTakeProfitMoveWithHidden
Extra pips to add to hidden SL for broker S L (or
% of Daily Range)
If true will modify broker SL if hidden SL is moved
Extra pips to add to hidden TP for broker TP (o r
% of Daily Range)
If true will modify broker TP if hidden TP is moved
Allows various confirmation message boxes to be turned on and off
If set then this file will be used as the configuration file for the EA.
If set the common data folder will be used when read ing/writing the configuration file of the EA.
This can be used to share the same configuration file for multiple instances of the EA on different accounts.
Issue 1.5 Page 23
Runwise Limited (UK)
www.runwisefx.com
Variable
Main_configInUnicode
Main_defaultMode
Main_defaultPeriod
Main_maxSlippagePips
Main_maxSpreadForAutoTradeOpen
Main_maxSpreadForManualTradeOpen
Main_pendingBuyOnBid
Main_indiDirPeriods
Main_indiDirShow
Main_hideTPLinesIfTradeNot
OpenUnlessSetManual
Main_maxSlippagePips
Main_pendingCancelOther
Description
Should be set if configuration file has been sa ve in Unicode (international) format
Default rule m ode to be used when EA loaded onto chart
Deafult period to be used when EA loaded onto chart
Maximum slippage when opening tickets, if -1 then uses spread
Maximum spread fo r which a trade open will be allowed to go ahead, in pips. Useful to prevent the EA from automatically opening a trade wh en the spread is especially bad.
As Main_maxSpreadForAutoTradeOpen bu t for when a trade is manually being opened
If true will alert/trade pending when bid pric e reaches target price
Comma separated list of periods for which the built-in direction arrows should be calculated and shown for
If set the will shown the built-in direction arrows on the control panel of the EA
If set then the hidden take profit lines will not be shown until a trade is op en. This can be useful to de-clutter the chart prior to trade open.
Maximum slippage allow ed when opening/closing trades, in pips
If true then opening of p ending will cancel any in other direction
Issue 1.5 Page 24
Runwise Limited (UK)
www.runwisefx.com
Variable
Main_resetAfterTradeClosed
Main_scaleInPrctDefault
Main_screenShotOnAutoOpen
Main_screenShotOnManualOpen
Main_selection*
Main_show*
Main_stopLossCalcTimeframe
Main_stopLoss[Min|Max]Pips
Main_tpAddSpread
Main_tpExtraPipsToAdd
Main_useAskForSLTP
Box_*
Style_*
Color_*
Issue 1.5 Page 25
Description
If true will reset setting to default after trade closed
Default percentage to scale-in by
Take screenshot when trade is opened automatically. Screenshots appear in the
MQL\files directory of the Data Folder and start with ‘rwfx_ss_’. Further control of screenshots can be made via inputs Gen_screenShot*.
Take screenshot when trade is opened manually.
Allows various selection lists to be altered
Allows various items to be shown or not
Default timeframe for auto stop loss
Min/max of calculated stop los s (can be % of
Daily Range)
If true will add spread to calculated take profit risk reward ratio prices
Extra pips to add to c alculated TP (say to cover commission)
Use Ask price for hidden stop loss and take profit where it w ould be used if broker
Use to position GUI control panel where you would like
Use to control the style of the various lines
Use to control the color of various items
Runwise Limited (UK)
www.runwisefx.com
Variable
Gen_fallbackPointToPipDivider
Description
If the EA can’t work out automatically how to convert points to pips then this value will used.
The default is 10, which is correct for ‘5 digit brokers’, i.e. that quote 10 th
of a pip. For ‘4 digit brokers’, i.e. who don’t quote fractional pips, then this value would need to be 1.
Issue 1.5 Page 26
Runwise Limited (UK)
www.runwisefx.com
9 CONTACTS
Runwise Limited
The Tramshed
Walcot Street
Bath
BA1 5BD
United Kingdom
Email: [email protected]
Web: www.runwisefx.com
END OF DOCUMENT
Issue 1.5 Page 27
Runwise Limited (UK)
www.runwisefx.com
广告