Stop Loss Orders In Automated Forex Trading

Stop loss orders are essential part of leveraged Forex trading, where the risk of margin call is significant. Manual trading without stops is of course possible, but it requires constant monitoring.  For automated trading, stop loss orders are evidently a must.

Here we will discuss some ideas how stop loss orders can be optimized in an automated Forex trading algorithm. We will suggest market adaptation of the stop loss orders position based on our pivot point detection algorithm.

As the base for our discussion, we will use our EURUSD Asian sessions testing example for our simple Forex Day Trading Strategy.  You can download the Smart Forex Tester and repeat this test yourself.

Our trading algorithm sets stop loss orders the next tick after positions opening, and then moves these stops in a trailing manner, securing the profit.

The screenshot below shows the very beginning of the test for the April, 24, 2105. In this baseline testing example, take profit value was set to 8 pips. Also stop loss orders were placed at a 8 pips distance from the trade, and were trailing market in the same increments.

Smart Forex Tester - Stop Loss Orders
Smart Forex Tester – Regular Stop Loss Orders

The first position opened was a short. We see that this sell order was closed profitably (leftmost green line). Few ticks after, the algorithm placed another sell order, which was a loser (leftmost right line). The stop loss oder was triggered almost immediately as the market continued higher.

The question is whether we would be better off setting the stop threshold looser? At least we could have the first position stay open longer, as we see that eventually market peaked and went down. And then we wouldn’t have the second loser trade at all.

On the other hand, with tighter stop, we had losses on the second trade, but then a new short position was opened very soon. And it turned out a success. You can see the stop loss order was trailed 5 times before it was triggered. The position yielded about 30 pips of profit.

Let’s see the test results for the looser stops.

Stop Loss Orders Set Further From Market

Looser stops  might be justified for trades with low leverage or without it. To simulate it, we increased the threshold for triggering stop loss orders. In the example above, we set it to 20 pips instead of 8.

Forex Tester Loose - Stop Loss Orders
Smart Forex Tester – Stop Loss Orders Set Looser
As expected, the first position was closed much later than for the tighter stop value. And we avoided placing the second (loser) sell order.
However, this didn’t increase our profit. As seen on the screenshot above, the looser stop loss order was also triggered later (green line) so the profit potential was used only slightly.
This simple example brings us to the conclusion that the algorithm must use some logic to modify stop loss orders and also adjust to the market situation.

Stop Loss Orders Modification Algorithm

First of all, it appears we should differentiate between the cases of initial placement of a stop loss order and the case of its trailing.  If looser stops are acceptable as such (e.g. no leverage), then it might make sense to wait longer for testing the market entry decision.
But when the position becomes profitable,  the stop loss order should be moved closer to the market. And even closer for each subsequent move. This will secure more profit when the market reverses.
Moreover, while moving the stops, we can make the distance between the stop and the market proportional to the size of the preceding market’s advance. In other words, the faster-moving is the market, the slower we can afford to approach it.
If a stop loss order is triggered during a counter-trend movement, it’s the trading algorithm’s task to re-enter the market.
Another idea is to move stop loss orders using our real-time pivot point detection algorithm.
On the screenshot below you see the same market data with detected peaks (red dots) and bottoms (blue dots).
The accuracy of the detection might not look ideal, but keep in mind that it was performed in real time! Meaning that for each detected extreme, only the market data that was available prior to that time, was used. And also note that the market data plotted is smoothened for better readability. Whereas the detection has to use real-time quotes that might fluctuate quite a lot.
Smart Forex Tester - Pivot Points Detection
Smart Forex Tester – Pivot Points Detection in Real-time
However imperfect, these signals are good enough for our purposes of modifying the stop loss orders. So, e.g. for the looser stop, if we used the bottom signals, we could have 2 of them around the very bottom and could have fixed almost maximum possible profit. See the 2 blue dots to the right of the black vertical cursor line in the middle.
If you found this post interesting, you can download the Smart Forex Tester software (includes Pivot Point Analyzer) and repeat this test yourself. We would be also glad to receive your comments.