Algorithmic Forex Trading: What it is and How it Works?

Algorithmic trading is a form of trading in which you use an algorithm, based on a set of predefined parameters, to open or close positions on your behalf.

Algorithmic trading aims to eliminate the human factor (psychotrading) and instead follows predetermined strategies based on statistics that can be executed while the market is open, using an algorithm with minimal supervision.

Many investors have long realized that machines can be excellent traders, as they employ strategies without human interpretation.

What is Algorithmic Trading?

Algorithmic trading involves conducting trades through processes and logic, automating your trading system and executing operations with a robot. Algorithms are used for this purpose, hence its name.

Algorithmic trading is also referred to as automatic trading or high-frequency trading. It puts your trading system into action with pre-established parameters, requiring no intervention beyond opening the broker.

In essence, it is a computer program that determines the positions to be taken, the direction of the trend, the volume to be traded, and finally, the strategy to be implemented.

While users still need to develop their own strategies, when applied correctly, these techniques can help traders take their hands off the wheel and let mathematics do the work.

Advantages and Disadvantages of Algorithmic Trading

As with any other trading system, there are both advantages and drawbacks to using an algorithmic trading system. Let’s explore what we consider to be the most significant ones:

Advantages:

  1. Goodbye to Psychotrading: By trading according to a set of established rules, an automated trading system will execute its operations as instructed without considering any other aspects outside the algorithm’s parameters.
  2. Tested Strategies: Testing your algorithm against historical charts can provide information about potential risks and profits before committing capital. This is possible, for example, with the strategy tester in Metatrader 4, which simulates your trading strategy in real-time and provides statistical data on the profitability of your algorithm.
  3. Fast Execution: An algorithmic trading system executes your trades much faster than a manual system. Since they operate based on algorithms, algorithmic trading systems can place and close orders as soon as the set parameters are met, allowing you to minimize losses and capture profits.
  4. 24/7 Market Monitoring: Algorithms can monitor markets 24/7, responding to market changes and executing trades even when the trader is not actively engaged. This ensures that trading opportunities are not missed.
  5. Diversification: Algorithmic trading allows for simultaneous execution of trades across multiple markets and assets, enabling traders to diversify their portfolios and manage risk more effectively.

Disadvantages:

  1. Need for Control: An automated system should not fail, and indeed it rarely does, but you should have a minimum level of control and daily monitoring of your algorithmic trades.
  2. Alignment of Theory and Practice: The creators of automated trading systems and algorithms must understand well what each requires. Properly configuring an automated system and putting it into practice is not easy.
  3. Sold Systems Aren’t Entirely Reliable: Many algorithmic trading systems sellers claim that their products are able to do the impossible. Don’t be deceived by these claims and make sure to thoroughly check any new system.
  4. Technical Risks: Algorithmic trading is vulnerable to technical glitches, system failures, or connectivity issues. These issues can lead to unintended and potentially costly consequences.
  5. Over-Optimization: Excessive optimization of algorithms based on historical data may lead to overfitting, where the algorithm performs well on past data but fails to adapt to new market conditions.
  6. Dependency on Technology: Traders relying on algorithmic systems are highly dependent on technology. Any disruptions, such as power outages or cyber attacks, can halt trading operations.

¿Do Robots Work in Algorithmic Trading?

The vast majority of trading robots available in the market provide unrealistically well-groomed results. The problem is that this is only true for a very limited period of time.

If you conduct thorough backtesting over a longer time frame and check the floating balance of the account, you will realize the reality: these robots delay losses, and there comes a point in the market where they can accumulate significant losses.

This doesn’t happen because it’s a trading robot or because it’s poorly configured; it happens because the strategy applied by the expert advisors is not profitable.

In summary, if the strategy you automate does not yield profits in a manual trading system, you have an automated robot that will never make money for you.

If what you automate is a tested system with proven profitability, then you have something that is consistently working well for you.

Automated Trading vs. Manual Trading: What is Better?

In my opinion, algorithms and algorithmic trading systems have their benefits, but the human factor in manual trading allows for greater reaction and flexibility.

Algorithmic trading systems only react to what they are programmed to respond to: they will sell when instructed to sell and buy when instructed to buy.

Sometimes, I get asked the following question: Do I absolutely need to create a trading robot to be profitable and make money? The answer is no. Algorithmic trading or expert advisors are not the foolproof formula for making money.

Algorithmic trading is a methodology for doing things in an orderly, methodical manner and maintaining an objective and realistic approach. It allows you to conduct yourself in a professional manner and be organized in terms of time and space.

This can also be achieved by implementing tools in your manual trading system, such as a trading plan, risk management, and keeping an up-to-date track record. If you apply money and risk management strategies correctly, these techniques can assist traders in taking their hands off the wheel and letting mathematics do the work.

How to Do Algorithmic Trading?

Let’s look at the phases and how to design an algorithmic trading system:

Phase 1 – System Design

In this phase, we will define what functions our system will perform, what information we need, what output it will generate, and all the operational details we need to consider. Using an example of a simple system based on the moving averages, in this phase, we will do the following:

  • Function: Make investment decisions automatically
  • Trading System: Cross between price and 20-period moving average.
  • Timeframes: 5m, 30m, and 4h
  • Trading Sessions: European Session.
  • Trading News: No
  • Trading Openings: No.
  • Platform: Metatrader 4.

Once the most important aspects of our system are defined, the next step will be to write our algorithm and the conditions under which the system makes decisions and differentiates between various choices.

Phase 2 – The Algorithm

The idea we need to work with in this phase is to write the algorithm as precisely as possible, considering all the details. This way, the implementation phase will become an almost mechanical process.

Continuing with our example, the algorithm would look like this:

  • Input Data / Variables:
    • Price, SMA 20, Equity, N.
  • Main Function: N=LotNumber()
  • If the price crosses SMA 20 from bottom to top: Buy N lots.
  • Place a stop loss below the tail of the previous candlestick.
  • Set a take profit 20 points above the entry price.
  • If the price crosses SMA 20 from top to bottom: Sell N lots.
  • Place a stop loss above the tail of the previous candle.
  • Set a take profit 20 points below the entry price.
  • Close Main Function.
  • Function LotNumber: // Calculate lot size
  • Equity * (risk) / Lot Size

After this, we need to implement the algorithm. Implementation is nothing more than coding the algorithm in some programming language, and the choice of language will depend largely on the platform where our system will run.

We are going to use the Metatrader platform and its programming language MQL4 since it is an easily accessible platform, and the MQL4 language is based on the popular C++ programming language.

Phase 3 – Backtesting

This phase is the most important; its mission is to test our system, check its performance, and fine-tune some parameters.

We will have an initial result to see how efficient and profitable our system is, and we will understand under what market conditions it performs best.

We will discover another very important piece of information, the maximum drawdown, or the maximum loss that the system can generate, which will be crucial when deciding the account size and the margin the system should have to avoid receiving a margin call.

To err on the side of caution, it is recommended to apply a correction factor of 20% to the obtained data.

Fase 4 – Real Market Testing

The considerations we must have in this phase are technical, especially if our system involves scalping or high-frequency trading. The speed at which data is received and orders are executed is crucial. In this case, it would be advisable to open an account with an ECN-type broker.

Examples of Algorithmic Trading Systems

Finally, I’ll show you a couple of examples of the type of entry a robot we are working on at Forex Dominion would make.

Example 1: AUD/USD

In the red arrow, the trading robot signals the entry, so it would execute the entry precisely on that candle, surpassing the wick of the previous candle.

Where would you place the stop loss and take profit?

  • Stop loss above the wick of the candle marking the maximum volatility point.
  • Take profit at the same pip distance as the stop loss, making our entry a 1:1 risk-reward ratio (risking €100 to gain another €100).

Example 2: USD/JPY

Similar to the previous entry, in the red arrow, the trading robot signals the entry, executing it precisely on that candle, surpassing the wick of the previous candle.

Where would you place the stop loss and take profit?

In the same location as the previous entry. We prefer working with 1:1 entries in the robot. We believe in a simple, easy-to-manage robot with adjusted risk profiles.

  • Stop loss above the wick of the candle marking the maximum volatility point.
  • Take profit at the same pip distance as the stop loss, making our entry a 1:1 risk-reward ratio (risking €100 to gain another €100).

Conclusions

  1. In my opinion, for a beginner trader, one of the best ways to approach the market is through education. Whether for algorithmic trading or manual trading, I believe you should learn many other things before entering the market with an algorithmic trading system that, generally, may not be created and tested by you.
  2. Once the algorithmic trading strategy is developed, the trader becomes a manager, not just an observer. Therefore, having prior education is crucial. A system requires constant monitoring of behavior and results to ensure maximum profitability with minimal risk.
  3. My recommendation, as always, is to test in a demo environment first and measure your results, as both manual and algorithmic trading allow you to do in the Forex market.

 

Leave a Comment