A Journey Into Automated Trading

I’ve not seen many threads on automated trading and after having some good back testing results with my cBot, I thought I’d document and log the process I’ve gone through and what I will go through further on. I have no idea if this strategy will truly work long term in reality but I’ll keep this thread updated from time to time win or lose.

Part 1 - Strategy

I’m not giving away my entire strategy, but it’s based on Heiken Ashi candles and is trying to pivot trade on lower time frames. This strategy adds to winning positions and also uses cost averaging to recover losing positions.

Primarily and maybe entirely this will be EURUSD. When there is big news, NFP etc trading will be disabled. Backtesting shows that the big news events can create big moves that don’t retrace and cause big drawdowns when cost averaging. However I have additional features that allow me to only buy or sell an instrument, so if NFP surprises to the upside I can just let it take buy positions until I see the market stabilise.

Trading times are only during London and New York. Right now I’m stopping the bot manually outside of these hours, but eventually the intention is to “set and forget” it except when big news events are incoming. I can automate the disabling of trading on these events, but I still want to be able to use discretion as to whether I switch on buy or sell only at these times, so it’s on the backburner for now.

The strategy may well evolve over time, but as a starting point I’m happy with where it is.

My backtesting shows that this strategy works on every time frame I tested. I have a preference for short term trades and they are more profitable but have more drawdown. 1 minute charts open too many positions for the small amount of capital I’m willing to risk on this, so I’m using 5 minute charts. Anything longer than that is too slow for me to supervise it live testing and would have to run through the night to work properly.

The position sizes are the smallest possible for my account at 0.1. This is spreadbetting, not CFD so don’t get carried away with what this means, it’s just different to what most of you are used to. If the account grows, I will increase lot sizes accordingly. I want to be able to hold a minimum of 60 open positions, so it will be a while before I can double that position size.

Here’s an image of the trades it’s taken throughout the day on Monday 4th December. If it’s not obvious, the arrow shows the direction and the line colour is whether it was profitable.

2 Likes

Part 2 - Backtesting

Unfortunately, I can’t 100% test the strategy because the discretionary stopping of trades at big news events isn’t easy with the cTrader backtester. It also, annoyingly, doesn’t take into consideration any margin requirements so the results are not completely fool proof. However Looking back at the results over 2023, the only times it takes anywhere near the amount of trades that I’ve set in my risk management is when unexpected news events come along.

In order to filter these out, I’ve set a higher starting balance than the real one. I could program in the big news events to switch modes etc, but it’s too much for the purpose of what I’m trying to prove. And eventually it all works anyway, just it created big drawdowns that are not what I’m comfortable with.

1st November 2022 to 5th December 2023 performance shows this:

The red circles on the equity plot are news events that it would have been stopped at, there’s a couple more that it would have been stopped at and there’s a couple of fairly significant drawdowns that it had which were not accounted for by news, but they are much smaller and within my acceptable risk profile.

That is trading fixed lots and not increasing as the account balance does. I’ve simulated increasing position sizes with balance, but the results are stupid and unrealistic so I’m not going to bother putting them up. But let’s just say if they’re real, then this time next year I will be much less busy :rofl:

1 Like

Part 3 - Beta Testing

After running a few days on a demo account to make sure it was taking the positions according to the backtesting, I put the bot into real world trading on a live account.

Day 1

The results were not good. But, this was not a result of the strategy not working, it was a result of my inability to control myself. I saw a fair amount of positions open and there was a red news event coming up. I decided that the only possibility was that the market would continue a strong trend so I manually put in large positions to account for that. The market then bit me and I turned what should have been a profitable day into a losing day.

Losses from stupid human = £123.85
Profit from stupid human’s pet robot = £81.66
Net loss = £42.19

Day 2

After a weekend to reflect on my idiocy, I decided I have to let the robot run without my interference. I do not know better than the strategy! I’m going to use the robot’s number from before because what I interfered with is NOT part of the strategy and I will not be doing it again unless things get much worse than a 0.5% drawdown…

Daily profit = £57.95

Total profit = £139.61

Day 3

Quieter day in the markets, had a really tight range in the middle of the day which means the robot couldn’t really do much. Got a small win in the morning, a flat afternoon and small win in the evening.

Daily profit = £16.96
Total profit = £156.57

Incredibly, that’s a 9% profit over 3 days. This account had about £1700 in at the start. I think the first 2 days were very suited to this strategy so it will not keep up this return, but the signs are very promising

1 Like

Part 4 - Next Steps

So that’s where we are currently. The robot is running right now but I missed the market open so it’s a little on the slow side probably until New York opens.

There are several things I want to do regarding development and use of the robot. Right now I’m running this from my work laptop whilst I do my job. That means I either have to stop it when I finish work or take the laptop home and miss a section of trading whilst I’m driving. I don’t like this situation. I can’t leave the laptop at work because I wouldn’t be able to stop the robot at night.

So the only real solution is to set up a VPS. I have no idea what I’m doing with this, but Microsoft have a system that’s integrated with my work account. I think that’s where I’ll start. All these trading specific VPS hosts fill me with the same dread of selecting a broker that isn’t a scam artist, except there’s no regulation whatsoever on hosting companies.

In order to run the robot from the VPS effectively, I need to add some GUI features to stop, start, pause, buy only, sell only, close all and some other features. This should make running it from my phone easier when I’m not in work.

I also need to do something about my home computing situation. The computer is too slow to be any use to anybody. I’ll have to buy a new one some time after Christmas and then I have more confidence in being able to access the VPS easily at any time.

Account tracking is also necessary. This is currently running on an account with a lot of history that isn’t relevant to this system. I don’t like that so will move this to it’s own account and set it up with myfxbook to track the results.

Next step is setting up the VPS, stay tuned…

1 Like

Basically you didn’t do autotrading because you all do manually

1 Like

Basically no. Every trade except the 4 oversized ones that caused the day 1 loss are made by the robot.

be careful, because you can’t count on back test. According to vps, you can check service which I am using

1 Like

I agree, the back test is not believable. There are too many flaws in it. This is why it’s a live test with me supervising it.

This is a journey that I’m documenting for the interest of the community and myself. It is not supposed to be me claiming I have the golden goose because the back test looks great. The intention is to go from the semi-automatic process that I have right now which requires my intervention to removing it. But finding the parameters to automate that isn’t necessarily easy.

2 Likes

Thank you for sharing your journey into automated trading. I’m looking forward to your progress.

I’m planning to make my trading as fully automated as I can when I start trading so I can minimize the losses from this stupid human. :laughing:

2 Likes

Virtual Private Servers for cTrader Automate…

@chesterjohn A few of these are UK Based… So probably worth a look for you…

2 Likes

First full week of automated trading has finished. Performance for the week is a gain of £127.88 which represents a 7.6% increase on the account balance. This is about 2/3 of the back test results averaged per week, but we don’t know if that’s down to market conditions or back testing not accurately reflecting reality.

Monday and Tuesday were very good for this strategy, the market moved how the back testing suggested and the performance was exactly in line with it. The rest of the week was much more flat, I thought this was pre-non farm payroll behaviour, so expected it to do better on Friday, but it didn’t materialise. The odd thing is that the market did the exact sort of moves that should be very profitable, except they didn’t have the right momentum so it was exiting early. We’ll see what next week brings.

I have created the new account to track on myfxbook, the link will follow later when I have everything set up on there. The funds need transferring across first, but there are positions open so I can’t do it until next week.

I have an Azure VPS set up. It’s free for 12 months, but doesn’t have enough RAM for me to be fully confident with it. I did run a small test and it took the same trades as my laptop with a 0.1 pip difference in slippage. Once I get my phone setup to connect to this, I will run it live so I don’t need the laptop on all day.

1 Like

Hey, nice to see another Algo trader. I have my Algo setup on Oracle cloud “Always Free” tier. My Algo doesn’t need high RAM or storage so it’s working pretty well for me.

1 Like

How much RAM does Oracle cloud have in the free version? I only need 2GB. It’s not expensive to buy one with that, but I want to prove out the strategy before I take the plunge to paying for something.

Oracle provides 1 GB RAM and 40GB storage (this is what I have). In the beginning stage of my Algo, when it used to take lots of memory and storage, I used AWS free for a year and Azure free for a year. The good thing happened after using both of them was I had to optimize my Algo because I wasn’t making any money to afford their cost. Now it can run under 1GB of RAM using 10-15 GB of storage. It scans 28 pairs for trade setup and takes approx. 18-25 secs.

1 Like

Thanks. The minimum RAM requirement for cTrader is 2GB, so 1 is a bit low. It does run on Azure with that, but it’s very slow. I’m thinking 4GB is probably best

1 Like

I’ve moved over to the new account and linked it to myfxbook to keep track of the performance more easily. You can follow this here Scalping Robot Forex Trading System by Forex Trader chesterjohn

This week’s performance has been in line with backtesting. Monday was on the old testing account and ended up at £51.06. Then I stopped everything so I could move across and get stats specific to this system.

Then the next 4 days it was up £183.15

That gives a total profit over 11 days of trading of £443.75

I’m absolutely blown away by this performance. From the start balance I was testing with, that’s a 26% increase, although I put little more into the new account to reduce the risk of position size vs balance. I expect at some point, a move will happen that breaks the system, but as long as the profit is this aggressive, it should result in an overall profitable system.

The manual intervention proved valuable last week. Backtesting shows slightly worse results than reality for next week, which was due to my intervention. If I could figure out how to automate that then I think it’d be a winner. Unfortunately, that’s beyond my coding skills as it’s based on my “feeling” rather than something directly inferred from a chart.

2 Likes

Without giving away full details what sort of price set-up is the system looking for?

It uses candle sticks to determine when price has peaked or troughed and then goes the other way. It’s basically trading constantly during London and NY.

It adds to winners only when the candlestick says it should keep going up and cost averages when the candlestick says price is about to go up.

I use HA candles to smooth the price action and reduce entries, but it works on normal candles too.

It won’t work on any pair, it needs a pair that swings up and down even during trends. For a more volatile pair, you’d need to filter for only going with the trend. That was where this system started.

I’m sure there’s a way to ride the trend better and not get out as early, but everything I’ve tried so far results in holding bad positions too long more often than riding the big winners.

1 Like

This is very clear thanks.

Adding to winners is tricky but must be the ultimate ambition for refining every strategy.

One way that is rewarding on some strategies is to hold until an opposing entry signal prints. I’m not sure my nerves would stand this.

1 Like

Adding to winners is a debatable subject. I can see lots of arguments either way.

This isn’t as much about adding to winners as it is taking every entry that says the next candle is going in your direction. Lots of small winners that should add up over time.

1 Like