GRat IndiTrade Manual

GRat IndiTrade Manual

29 November 2022, 16:29
Ivan Titov
0
276

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, which is convenient, for example, for automatic trading on crypto exchanges through GRat_Crypto or GRat_BinanceImport, and there is no need to allow  Algo Trading.
DrawVirtTrades - if true, then the levels of open virtual orders and positions will be shown on the chart.
Magic - a magic number to separate trades of this instance of GRat_IndiTrade from other trades.
PercentagePoints - true - all ..Points parameters  are set as a percentage of the price, false - in price points.
=== Open === - parameters for opening a position (in addition to trading signals).
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; Proportional - calculated for the current balance by the ratio of the FixedLot and ProportionalBalance (e.g. if  FixedLot=0.01, ProportionalBalance=500, current balance - 1000, then lot size will be 0.02); Risk - calculated according to the given risk of loss as a percentage of the balance; Margin - calculated based on a specified percentage of the margin.
FixedLots - fixed lot size (for LotType=Fixed or Proportional).
ProportionalBalance - the balance for FixedLots and LotType=Proportional.
RiskPercent - risk percentage (for LotType=Risk).
MarginPercent - margin percentage (for LotType=Margin).
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 (position management).
SLFromCond — if true, then real SL will be set at the level equal to the value of the left side of the first comparison of the closing condition.
TPFromCond — if true, then real TP will be set at the level equal to the value of the left side of the first comparison of the closing condition.
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.
TPOnOpposite - if true, then the take-profit of the position is placed on the nearest opposite Limit order, if any.
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}, {balance}, {profit}, {profit%} (the last 2 are only for CloseMessage). 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=1.02, TP=1.04when triggered.
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.
TelegramAlert - send a message to Telegram. Attention! Allow WebRequest for URL: api.telegram.org in MT5.
TelegramToken - token of the Telegram bot that is the administrator of the channel or group for messages.
TelegramChannel - name of the public channel for messages, or
TelegramChatID - ID of the channel or group chat for messages (you can get it by adding the @LeadConverterToolkitBot bot to the chat and sending the /get_chat_id command).
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 https://some.com/api/open?symbol={symbol}&side={buy_sell}&qty={lots}&price={price}" will be replaced by https://some.com/api/open?symbol=EURUSD&side=buy&qty=0.01&price=1.03 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 - https://some.com/api).
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).
FontSize - font size of panel controls.
MaxInfoLines - the maximum number of lines in the strategy description.

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


4. On the chart in the Condition Setting Panel, set the condition (trading signal) 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 (trading signalto open sell. For example, when the fast MA crosses the slow MA down on the last closed candle:

Note: The arguments of the conditions can be not only indicators, but also the values ​​of the current price and parameters of the candles (including average, maximum and minimum for a specified number of last candles):

Prices:
Bid
Ask
Last
Candles:
Open - opening price
High - maximum price
Low - minimum price
Close - closing price
Middle - the middle between High and Low of the candle
Highest - the maximum price of the specified number of the last closed candles
Lowest - the minimum price of the specified number of the last closed candles
Tick Volume - tick volume
Real Volume - real volume
Body - body size in price units
Upper Shadow - size of the upper shadow in price units
Lower Shadow - size of the lower shadow in price units
Size - candle size from High to Low in price units
Gap - distance between the opening of the candle and the closing of the previous one in price units (up - positive, down - negative)
Average Body - average body size of the specified number of the last closed candles in price units
Average Size - average size from High to Low of the specified number of the last closed candles in price units

On the right side, you can also set a constant value (Value), value shift   and multiplier .

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! Press   button to view the strategy description (list of configured conditions):


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.

Chat.

Examples

Based on custom indicators:

PriceChannel_Signal_v2

Learn how to design a trading system by: