Trade the News, but make your FOREX research! Part 1 — The trading algorithm
Trading FOREX on economic news releases can result in unexpected losses if somebody isn’t careful enough. I made a FOREX news trader algorithm with more than 20 parameters to help me navigate during this volatile period. In this first article, you can read about the idea behind the strategy and the forex news trader itself. In the next article https://medium.com/@istvan.veber/trade-the-news-but-make-your-forex-research-part-2-analysis-and-strategy-e0f2c84a3bdd, I will show you what kind of analysis I make for selecting the events to trade and setting the parameters. The third part is about EDA, model fitting, and selecting the best parameters: https://medium.com/@istvan.veber/trade-the-news-but-make-your-forex-research-part-3-eda-random-forest-and-parameter-selection-456271c7febd
When I first met the FOREX world in 2016 and tried to learn the basics and build my first strategies, I always was warned: don’t trade the news! And I followed this advice for a long time, I preferred price action trading, but I was watching the high volatility during economic news, learned about the main market mover events, and wanted to build some strategy which can result in a statistically significant profit/loss ratio.
Manual price action trading is fun for a while, but after some months I felt it tedious. My strategies demanded too much time before the charts waiting for a good move, and if Trump posted something on Twitter, or unexpected news came out my conception was ruined. I became more interested in algorithmic trading solutions and I felt that there must be some pattern behind the volatility during the economic news. The other reason news trading was attractive to me is the instant result. I set up my parameters and most of my trades takes only some seconds or minutes. (Later it turned out that setting up the parameters with my half manual, half automatic approach takes 10–30 minutes for one event, but the trade itself is quick.)
The raindrop metaphor
In my mind, I imagine the FOREX world as a surface of a lake during a rain. There are always waves because of the wind and the raindrops, these waves meet and at the and it is impossible to say what exactly caused the actual wave. Of course when somebody throws a large rock into the lake, the waves will be separable for a longer time, but eventually, every old effect will be indistinguishable. But for a very short time in the close vicinity of a raindrop, we can clearly see the concentric waves moving away from the center (if we are in mild rain and not in a storm :) ).
This close vicinity of a raindrop, or in our case the close vicinity of economic news is what I examined and trade.
Ok, I know, every metaphor always lie a bit (or a lot). There can be multiple news releases at the same time, the average surface of a lake is on the same level, and a currency pair can move in the same direction for a long time, but I wanted only to introduce the main idea behind the strategy, and I will speak about the problems and difficulties later.
I distinguish three main opportunities to trade the news during the first milliseconds, seconds or in the first 10–20 minutes. 1. Ride the first wave of the price-jump and trade in the direction of the jump. 2. Catch the peak and from there trade in the opposite direction hoping that there will be a large correction. 3. After the jump happened, the price often goes in the same direction for a relatively long time. We can try to evaluate this direction and trade it.
In the next article (Part 2), I will show you how I set up a strategy for the first type of opportunity, how I select the events and the parameters to trade them, but first, here I will show you my trading algorithm.
A trading example
My trading algorithm was built for the first type of opportunity from the above trio, but it has more than 20 parameters, so it is able to trade very different strategies.
The idea itself isn’t novel, the trader helps to apply a non-directional bias approach, or straddle trade. At the moment the FOREX trader doesn’t care about the news related numbers like consensus or the actual data, I wanted only to ride the big move. It would be fantastic if I could exploit the information of the news before the jump, but with my resources (or with your resources if you aren’t a member of some very well capitalized high-frequency trading group) it isn’t possible. The jump will be over by the time you can evaluate the information and place your order on a far away server. But with the properly set ensemble of pending orders waiting for the big move, there is a chance that you catch profit in the wave.
A demo trade:
During a typical trading scenario, I open multiple pending orders with very different parameters in both directions, or only in one direction if the earlier analysis shows that during the actual event only the short or long positions have good chance to make profit. Quantitative parameters like stop-loss or take-profit are different for all orders. With this setting, I try to avoid the situation when the positions are closed at the same price. Before the news, I continuously modify the pending orders to keep the predetermined distance from the price. I use this technique because placing a new order takes more time than modifying a pending order, and if my new order is late only some milliseconds, I missed the jump. But if we use pending orders, at the time of the jump everything is set properly (at least technically). When the jump happens and the first order is filled in one direction, all of the orders are canceled on the opposite side. After that, the trader manages only the “jump-side” orders. If there are pending orders further away they can be filled as the price reaches them, but if they are unfilled for a predetermined period, they will be closed. Eventually, all take profits or stop losses are triggered, and we finished our trade. If our setup was for multiple events, the trader waits for the proper time and opens new orders for the next event. It is possible for example to setup everything on Monday for the upcoming events of the week.
Parameters to play with
You can read about all the parameters on the GitHub page https://github.com/sinusgamma/Forex-News-Trader-Dukascopy-API, but here I mention the most important ones for trading.
Naturally, it is possible to choose the event and the instrument we want to trade. We can select the enabled order directions. For all pending orders, we can determine how far they will be from the price when the news comes out and what is the take profit or stop loss distance. We can set multiple parameters to manage our pending orders before news time. To manage our filled orders the break-even parameters and the trailing parameters can be useful. If we don’t want to delete the pending orders on the opposite side, we can use the order-cancel-order parameter, and there are some parameters to manage our risk and capital. A very important parameter is the maximum spread. If the order isn’t filled yet and the spread is higher than a threshold, the order will be automatically canceled. It is possible to set the max slippage similar to the maximum spread because Dukascopy enables slippage control, but I don’t really use it lately.
Do your testing
I don’t trade any news without analyzing and testing. It is possible to test the strategies in Dukascopy’s JForex platform, but for my purpose, that tester wasn’t suitable. Instead of that, I built my own multi-parameter tester which is able to test thousands of combinations and at the end saves its findings to a nice .csv report. A small part of an “excelized” version can be seen below. I will speak more about my process of how I select the parameters to trade in the next article.
About the code
I built this Forex News Trader in java. Dukascopy has a fantastic API https://www.dukascopy.com/wiki/en/development/strategy-api, which made it easy to implement most of the logic, but as every API it has it's dark (or grey) side as well.
Acknowledgment
Some ideas for this trader comes from an early version of amazingEA https://www.forexfactory.com/showthread.php?t=541311, but I got only some ideas, amazingEA was free for a while, but not open source.
Analysis and Strategy
In the next article https://medium.com/@istvan.veber/trade-the-news-but-make-your-forex-research-part-2-analysis-and-strategy-e0f2c84a3bdd I will show how I choose the news and instruments to trade, and how I select the parameter scenarios.