Demo of trading bot for forex - an intro

A diversified automated forex trading system that swings and scalps

This post goes with the following video intro to the bot.

As mentioned in the video, I’ve been a retail trader for near on 5 years now, but during that time have been developing automated systems. Mainly on the MetaTrader platform. I started on MT4, hit some limits with bad data, used special tick data software then abandoned that for MT5 which offered better backtesting and broker’s tick data. Over that time I’ve worked with friends and contacts on the quant/dev side of finance in NYC, Chicago, Switzerland and Australia. Some pretty great minds who all had their own ideas and methods. The best practices among all of them were a common theme, around data, testing and robustness, but everyone tended to develop their own approach to the market.

We even got to the stage of challenging each other to make a random entry bot profitable. Risk management, it turns out, is that important. But with a sound model, based on profitable real-world trading, in addition to the risk management, you can do much better than that. Then further diversifying systems to to mitigate risk clustering and adjusting risk management to suit the conditions starts to really round off an automated approach.

But automating something so complex is a huge challenge, so the use of a hybrid system that overcomes human errors while making the most of human intelligence is an attractive direction to pursue. Particularly after experiencing the challenges of manual trading first hand.

What it is - the semi/fully auto diversified bot

There are a few ways to define the automated terms, but in this case semi-auto trading applies to exits by default, with an option for entry approval too. So in practice you leave the bot to make its entries and you manage the outcome, being careful not to exit trades too soon, focusing more on exiting in good profit (2R+, or over 2x risk) to help the bot along. If you are unable to assist the bot, it can manage things on fully auto, covering your trade at breakeven past a certain point or starting to unload positions under various conditions.

It is diversified because it includes multiple, different entry criteria. The swing part of the bot trades on the hourly chart, H1, and the scalping part on M5. The risk profiles are different to reflect the frequency and probability levels of trades. Combined, on fully automatic mode, the backtests showed good profit to drawdown ratios, giving confidence that even without human intervention they can look after your account well.

Depending on the experience level of the human intervening, it can both help or hinder results. As such, it’s aimed at existing traders with decent sized accounts, with the expense of the bot itself representing around 1-3 months of profit derived from it. Users would be experienced traders, or even small funds, and would be wary of bots that don’t manage risk correctly (turbo hamster etc.) and want to have full control while also allowing for a system to look after itself.

Beginners have a tendency to meddle too much, or illogically, struggling to make it pay for itself with a small $500 account. They take too much or too little risk and don’t understand the underlying strategies. At minimum I’d suggest familiarity with MT5 and running EAs and indicators, an account of no less than 5k USD/GBP/EUR etc. It does work on smaller accounts, but this is more of an experience filter for the time being.

How it makes money

Being diversified between swing and scalp modes, on H1 and M5, with different risk profiles, the former is based on strength movements around key areas, the latter on volatility in the short term.

For the swing side, I have built a strength index that, from what I’ve seen out there, is likely the best on the market. It’s a smoothed, normalized, highly reactive indicator that gives an accurate read of whether currencies are diverging (trending) or converging (ranging) over any time period. I have used it with some success on M1, because its look back period is so long it’s effectively like trading a higher timeframe with a better resolution. However for the bot and automated systems its much better to trade M5 and above for short term moves, as it aggregates moves to a level where costs are a much lower percentage of profits in real-world trading.

As for the key areas it trades currency strength reversals around, I’ve employed a very flexible yet simple method. A lot of devs try to find local key areas, maxima and minima, using zig zag or variations on moving averages. This works to a point but is very resource heavy, requiring a long look back for every calculation, and it doesn’t work when price moves into a new area. After looking at the order book through tools like Bookmap and Quantower, it confirmed to me that massive order clusters do indeed sit at certain areas that take zero computation, and can be further filtered and confirmed by the strength indices. So whole numbers, half numbers are our proxies for support and resistance. This works surprisingly well.

As mentioned, if currency strengths are reversing around these areas, we have a potential price reversal. The bot is built to account for “fake” reversals in its risk management, getting you out safely if the move doesn’t follow, giving a very robust swing system to run on H1. Running on the hourly means lower stress, giving you hours to decide whether or not to stay in trades, or let the smart, pre-programmed risk management handle it for you if undecided.

Backtests show it comes out on top over time, with the only major improvements being the exit at peak profit rather than let it hit the trailing stop.

Why use a bot at all?

I have had a few very sound systems based around strength indices, volatility and VWAP bands for a year or more now. I was so confident that I took on a funded trader “prop challenge” at the end of 2020. It didn’t pan out because I made a stupid mistake, holding onto and trying to hedge my way out of a dumb position. Same happened on my second effort. Everything, or the majority, given by the system worked while I was messing around going off book. This is how I came back to the idea of semi-auto. No matter what mood I’m in, or how stressed I am, or what ideas I have, the bot will smooth these over. You hear of traders struggling for years with these things and I think I’d be in the same boat. So this is a crutch. I know what I’m doing, I just need helping over the psychological obstacles. If the system is based on how I’d ideally trade anyway, with low stress, high odds positions and secure risk management, then all the better.

I’ve also done semi-manual trading before and actually had my best run over 75+ trades, and the least stress doing it, so wanted this strat to work semi-auto to fully-auto. This fixes the issues I had and lets me get back to using the strat correctly. Since the challenges I further improved the system based on the experience, and there are no doubt further improvements to come. I’m looking at risk-scoring, adding an equities model and increased fault-tolerance.

Performance and fault tolerance

As I’ve designed it, it can run on 10+ year old PCs without spinning up fans, using single digit % of CPU. I know this because I initially developed it on one such machine, the trusty Z600 with Xeon processors. Surprising how well it held up for all that time. The bot essentially only calculates once per bar rather than every tick, loading only the minimum required data and dependencies into memory. This uses OHLC data rather than tick data, being faster to iterate through testing phases and more robust in terms of what data brokers offer for testing and live.

Closing words

I’d love to show you the indicators behind it and explain in detail how it works, I love all that stuff, but that won’t allow it to keep its edge as efficiently. It’s not smoke and mirrors though, it’s all novel calculations based on real-world phenomena with risk management using near-optimal human criteria (tested over 100s of variants). These indicators I’ve made are ones you won’t have seen before. I know because I’ve trawled the MT repo and TradingView etc. They are novel ways of calculating volatility, and of calcing strengths in pairs, among other things. I’ll do private showings for interested parties, for sure. So do get in touch, ask me anything, otherwise I’ll keep showing and telling what I can.

Subscribe to the mailing list for updates, discounts and offers




Published by and tagged automation using 1461 words.

Next:
Previous: