GRat IndiTrade Manual

GRat IndiTrade Manual

29 November 2022, 16:29
Ivan Titov

Manual for GRat IndiTrade

MT5 & EA setup

Run MT5 on any account (even demo). Next, we will create an example of a robot that trades with indicators without writing or generating any code, and run and test it without any compilation!

1. Allow Algo Trading if automated trading in this terminal is required.

2. Open a chart with the desired symbol and timeframe. Add the required indicators to it and set the required parameters for them (for example, fast MA with a period of 10 and slow MA with a period of 20):

3. Add the GRat_IndiTrade EA to this chart. On the Inputs tab, enter the parameters:

Trade - true - enable real automatic trading. Attention! Algo Trading must be allowed. false - all trades will be virtual.
Magic - a magic number to separate trades of this instance of GRat_IndiTrade from other trades.
=== Open === - parameters to open position.
Session - session time when it is possible to open positions (empty - not set).
OrderType - order type. Possible values: Market, Limit, Stop and Stop Limit.
PriceFromCond - if true, then the base price of the pending order will be equal to the value of the left side of the first comparison of the opening condition, false - current market price.
StopIndentPoints - indent from the base price in points for placing Stop and Stop Limit orders.
LimitIndentPoints - indent from the base price (or from the price of a Stop Limit order) in points for placing a Limit order.
LotType - Fixed - fixed lot size, Risk - calculated according to the given risk of loss as a percentage of the balance.
FixedLots - fixed lot size (for LotType=Fixed).
RiskPercent - risk percentage (for LotType=Risk).
MaxPositions - the maximum number of simultaneously open positions and orders (0 - no limit).
PerDirection - if true, then MaxPositions is applied separately for each direction: Long and Short.
NextAfterOpposite - if true, then the next order is only possible in the direction opposite to the previous one.
NextAfterBars - the number of candles after which the next ordercan be opened.
NextAfterPoints – loss of an open position in points, after which it is possible to open an order in the same direction (averaging technique).
ExpirationBars – pending order lifetime in bars (0 - no limit).
MaxOrdersPerSession – the maximum number of placed orders per session (0 - no limit).
=== Close === - parameters for closing a position .
CloseByOpposite — if true, then the open trade is closed on the opposite open signal.
DeleteOpposite — if true, then when opening a position, opposite pending orders are deleted.
SLPoints - stop-loss in points (0 - not set).
SLOnOpposite - if true, then the stop-loss of the position is placed on the nearest opposite Stop order, if any.
TPPoints - take-profit in points (0 - not set).
TPFactor - stop-loss multiplier to get take profit-value.
TrailingStop - enable trailing-stop (stop-loss following the price).
TSStartPoints — current profit of an open position in points, after which the trailing-stop starts working.
TSPoints — distance from the current price in points, at which the trailing-stop places the stop-loss.
TSStepPoints — stop-loss change step in points at trailing-stop.
TrailingTake - enable trailing-take (take-profit following the price).
TTStartPoints — current loss of an open position in points, after which the trailing-take starts working.
TTPoints — distance from the current price in points, at which the trailing-take places the take-profit.
TTStepPoints take-profit change step in points at trailing-take.
TTBars — the number of bars after opening a position, during which the distance from the current price, at which the trailing-take places the take-profit, decreases (evenly on each bar) to 0, and the position is closed (0 - disabled).
TTBE — if true, then the trailing-take moves the take-profit only to the breakeven level specified in the BEPoints parameter below.
Breakeven - enable breakeven.
BESetPoints — profit of an open position in points, after which breakeven is triggered.
BEPoints — profit of an open position in points, on which a stop-loss is placed at breakeven.
BEClosePercent — percentage of the open position volume, closed at breakeven.
TargetsPerSession - if true, then stops trading until the next session starts (the Session parameter must be set), if false - until the EA is restarted.
TargetsUnit - units of target profit and loss values: % - as a percentage of the initial balance, Currency - in the deposit currency.
TargetLoss - target loss value (maximum drawdown, 0 - disabled).
TargetProfit - target profit value (0 - disabled).
DeleteTime - time to delete all pending orders (empty - not set).
CloseTime - time to close all positions (empty - not set).
ZoneRecoverySteps - the number of Stop orders opened to recover losses using Zone Recovery technique (0 - disabled).
=== Send === - notifications when specified conditions are met.
OpenMessage — message text when opening a position. Placeholders can be used in the text: {symbol}, {timeframe}, {open_close}, {long_short}, {buy_sell}, {opder_type}, {lots}, {price}, {sl}, {tp}. Instead of placeholders, the corresponding values ​​are substituted. For example, {symbol}, {timeframe}: {open_close} {long_short} {lots} at {price}, SL={sl}, TP={tp} will be EURUSD, H1: open long 0.01 at 1.03, SL when triggered =1.02, TP=1.04.
ModifyMessage — message text when changing SL/TP of position (placeholders can be used).
DeleteMessage message text when deleting a pending order (placeholders can be used).
CloseMessage message text when closing a position (placeholders can be used).
Print - output a message to the log.
Comment - displaying a message in the upper left corner of the chart.
Alert - display a message in a separate dialog box.
Notification - send a push notification to a mobile phone.
Mail - send an email.
SoundFile - setting the sound file to play.
CopyToFile — if true, then all deals are copied to the OrderExchange<Magic>.csv file (where Magic is a unique magic number specified in the corresponding parameter). This file can be imported, for example, into the GRat_Crypto and GRat_BinanceImport tools for automatic trading on crypto exchanges as well as into GRat_OrderImport (MT4).
Common — if true, then the OrderExchange<Magic>.csv file is located in the common folder of all client terminals ..\Terminal\Common\Files, if false - in the folder of the current terminal ..\MQL5\Files\.
OpenWebRequest — HTTP(S) request (for example, for some external REST API) sent when opening a position. At the beginning, the request method is specified (POST by default), then, after a space, url addresses using placeholders (see OpenMessage). For example, the specified request{symbol}&side={buy_sell}&qty={lots}&price={price}" will be replaced by when triggered . Attention! In the terminal settings on the Expert Advisors tab, you need to allow WebRequest for the URL used in the request (in the example above -
ModifyWebRequest — HTTP(S) request (similar to the one above) sent when changing SL/TP of position (placeholders can be used).
DeleteWebRequest — HTTP(S) request (similar to the one above) sent when deleting a pending order (placeholders can be used).
CloseWebRequest — HTTP(S) request (similar to the one above) sent when closing a position (placeholders can be used).
=== Dashboard ===

ScalePercent - panel size in percentage to original  (in case of custom system font size).

After launching the EA, the Condition Setting Panel will open:

4. On the chart in the Condition Setting Panel, set the condition to open buy. For example, when the fast MA crosses the slow MA upwards on the last closed candle:

5. Switch to Sell and set the condition to open sell. For example, when the fast MA crosses the slow MA down on the last closed candle:

6. If necessary, you can set the conditions to close positions and orders. For example, if the price came back behind the slow MA:

7. You can set complex conditions. For example, let's add a RSI buy entry filter to buy only in oversold zones (30). To do this, add the RSI indicator to the chart, then add one more part (AND, +) to the buy open condition (Buy, Open):

If set to AND, then each part of the complex condition must be met; if OR, then at least one of the parts must be met.

8. Similarly, let's add a sell entry filter by RSI to sell only in overbought areas (70).

9. Robot is set up! Save all settings in a chart template (.tpl).

10. Run the robot:

11. To launch the robot on another symbol and timeframe, for example GBPUSD, M30, just open the required chart, load the saved template on it and run the robot:

12. For visual testing of the robot, save the chart template with the configured robot and indicators (like in p.9 above) to 2 files: .. MQL5\Files\GRat_IndiTrade.tpl and .. MQL5\Profiles\Templates\tester.tpl. Then, in the Strategy Tester set the tester parameters in the Settings tab (check the visual mode), then the EA parameters in the Parameters tab (or load them from a set-file previously saved after p.3 above) and run the test:

A template with the settings of the robot discussed in this manual is attached.



Learn how to design a trading system by:

Share it with friends: