Creating Expert Advisor in R Trader From Scratch: Practical Advice

Creating Expert Advisor in R Trader From Scratch: Practical Advice



Trading on a currency or stock market requires a set of rules to comply with — this is the only way to success. Even long-term investing includes following certain rules, which regulate the choice of the asset and calculation of the term of the investment.

Trading systems

Such a set of rules may be called a trading system. The latter may be based on either the technical analysis or fundamental analysis.

Tech analysis implies an analysis of the chart of an instrument. It is carried out with the help of various indicators or well-known price patterns.

Fundamental analysis includes analyzing news, insider information, statistics, etc., which helps imagine the current dynamics and forecasts further price movement.

Trading robots

When the trader makes up their mind about the type of analysis most suitable for them, they start trading. With time, their trading nears perfection, becoming their daily routine. And then, the trader decides to automatize their strategy.

Fundamental analysis is rather hard to automatize; this requires programming skills to create robots that can "read and analyze" the news. Some experience of working with artificial intelligence is even better. So, the number of such traders is rather limited while the efficacy of such systems is no higher than of those based on tech analysis.

A trading system based on technical analysis is much easier to automatize. If it consists of indicators, it is enough to know the programming language of the trader's platform.

For example, on Forex the most popular platform is MetaTrader 4. To write a trading robot for this platform, the MQL4 programming language is necessary, i.e. you need to study a programming language.

Where can you create a robot without programming skills?

Markets are developing, and new opportunities for automatizing trading systems appear.

A great option for creating a trading robot for those who do not know any programming language will be a multi-market platform R Trader. It has a built-in simple and intuitively understandable strategy constructor. It is meant for automatizing your trading system if you have no programming skills. All you need is a moderate experience in trading so that you understood what is a closing/opening price and the minimal/maximal price of the candlestick you are interested in.

Description of the trading system

I will try to answer all of your possible questions by showing you how to create a trading robot on R Trader on the example of a very simple trading system consisting of two indicators.

The first and the most important thing you will need at the start is a trading system. It must have clear rules of opening buy and sell positions. To avoid mistakes, you should draw all the indicators on the chart.

In our case, opening a Buy position will look like this:

Description of the trading system in R Trader

1. Moving Average (EMA) — 200, Close, 0 — less than the closing price of the current candlestick.

2. The lower border of the Bollinger Bands Low (20, Close, 2, 0) is above the minimum price of the current candlestick.

If these two conditions are fulfilled, then a Buy position is opened.

Description of the trading system in R Trader

Now let us describe the conditions for closing the Buy position.

1. The upper border of the Bollinger Bands High (20, Close, 2, 0) is below the maximum price of the current candlestick.

2. Moving Average (EMA) — 200, Close, 0 is above the closing price of the current candlestick.

Creating a trading robot

I have shown you how to describe an entrance point for a Buy. Now we need to transfer it to the R Trader platform.

We log in the platform and click "Strategies" — "My Strategies", then click "Add new strategy".

Creating a trading robot in R Trader

Next step, you will need to invent a name for your strategy and describe it briefly.

After these steps are complete, you get to the constructor itself, where you specify the parameters of your trading system.

To start with, the constructor suggests setting up the condition for a Buy position. As long as we have described them above, it will be enough to just choose the corresponding parameters of the indicators and specify the conditions.

Creating a trading robot in R Trader

Now, we need to specify the closing conditions described above.

Creating a trading robot in R Trader

Additionally, you can set up the Stop Loss and Take Profit values (close at SL and close at TP, respectively). If these values are specified, the position will be closed at the condition that is fulfilled first.

So, we have formulated the necessary conditions for opening and closing a Buy. Now let us check whether this system will demonstrate good results.

For this, choose your preferred instrument, choose a timeframe, "Order volume", and click "Backtest".

Creating a trading robot in R Trader

Testing the trading strategy

Testing is performed historically, the timeframe is picked up by the platform and depends on the number of testable quotations. Unfortunately, you cannot upload quotations for longer testing here.

If we have done all right, the results of testing will appear.

In our case, the strategy demonstrates a positive result with a profit of 1,304 USD. A negative result would have meant that the system needed reworking.

In this tester, the starting deposit is not specified. The growth of profit starts from zero, so everything below zero can be considered a slump. This strategy showed a slump of 400 USD at the very beginning. Then all losses were covered by the money earned.

Testing the trading strategy in R Trader

However, this is not it, and the result can be enhanced by adding some more standard conditions. Go back to editing the strategy (click "Editor") and type 2 in "Max open deals".

Testing the trading strategy in R Trader

By this, we allow the trading robot to open a second position even if the first one has not closed yet.

"Max open deals" lets open new positions before the previous ones are closed. I must warn you that in this particular strategy the parameter works incorrectly. The conditions are checked on every tick, and in one minute a whole load of positions may be opened.

To avoid such a situation but still be able to open a new position at a better price, we can use the "Enter every 0 ticks above last entry" function. It allows opening a new position a certain number of points above/below the previous one. Instead of zero, type in the necessary number of points.

Testing the trading strategy in R Trader

Additionally, in "Multiplicator" we type 2, by which we tell the robot to make the volume of the second position 2 times bigger than that of the first one.

"Multiplicator" multiplies the volume of the previous order by the value specified in it. Click "Backtest" and check the new results.

Testing the trading strategy in R Trader

Launching the trading robot

If we are satisfied with the result, we only have to launch the strategy.

To do it, click "Enable"; a window will appear. In it, you should specify the volume of the opening position and the TP and SL in the USD, if desired. If the two last boxes are left blank, the positions will be closed at the conditions implied by the strategy.

The choice of the instrument is performed automatically. In our case, the program will choose the instrument the chart of which is currently on the screen. This is US500.

After the launch of the strategy, we can check the name and all the information (such as the time of launching, the instrument, the timeframe, the profit, etc.) about it in "Running Strategies".

Launching the trading robot in R Trader

Same way, we can launch the strategy on any instrument that it shows a positive result. However, you will have to calculate the volume of the trade for each instrument to avoid exceeding risk limits on the deposit as the simultaneous closing of all positions on the account with a loss can cause serious damage to the deposit.

To delete the strategy, it is enough to click the cross at the end of the line.

With R Trader, unlike MetaTrader 4 and MetaTrader 5, there is no need to keep your computer on all the time for the robot to trade. Neither do you need a VPS. You only need to launch the robot on the platform, and then it starts trading on the server automatically.

While trading, you can close the positions manually and alter both the order and the strategy itself. You can put the expert advisor on a halt or simply delete it if your results are worsening.

Yet another advantage of the trading robots on R Trader is the vast selection of instruments, including the stocks traded on European and American exchanges, currency pairs, and cryptocurrencies. Thus you can try one robot on several markets, otherwise, you would have had to create a separate robot for each platform and study programming languages, which is time-consuming.

Summary

Now you see that anyone can create their trading robot. A platform features standard trading strategies, all of them having their work conditions transparent. In our case, you can enhance them according to your ideas and find the best instruments for them.

All you need is a strong desire to progress in trading and use all the opportunities for making a profit on financial markets. One such opportunity is discussed in this very article.



Left unedited for writing style, spelling or punctuation.


Previous article

Uber: Failure of IPO. Reasons and Consequences

On May 10th, 2019 NYSE hosted the IPO of well-known Uber (NYSE: UBER). This event was watched closely by the financial world as this IPO was considered one of the largest ones in 2019. Apart from all media being concentrated on the event, the company notified its drivers all over the world, giving them bonuses for the stock purchase. Thus, this IPO should have become not only the largest but the most successful one.

Next article

Trailing Stop: Simple and Reliable Helper

The Trailing Stop is a much flexible and comfortable way of using the Stop Loss. With this instrument, the trader gets an opportunity to use the whole potential of the market movement, simultaneously reducing the risk of large losses.