How to automate a trading strategy

Hi,
I’ve develloped a scaping strategy based on news events that seems to work when I backtested it manually for the last 10 years. The problem is that the market needs to be entered extremely quickly while taking into consideration the last candlestick closing price after the annoucement of the news, way quicker than a human could. To solve this problem, I thought about automating my strategy, so that the trade would be placed almost instantaneously. I wondered what options I had. Should I simply learn to code? If so, what language should I focus on? Should I use an AI that does the coding for me? What AI would you recommend? Should I buy a already existing bot and adapt it to my needs? I am new to this, and your help would be greaty appreciated. Thanks!

2 Likes

You can use python to code your strategy. It’s an easy coding language to learn.
I suggest the TA-Lib + the Metatrader 5 Python Libraries.
TA-Lib can be used to compute indicators such as SMA , ATR etc …
metatrader 5 library can be used to get data, execute orders etc …
You can use chatgpt to get started with it. If you have any problem, you can post them here and i’ll try to help :slight_smile:

1 Like

Sorry, I am not judging but base on this sentence, I would assume that you’re trying to look for entry after the news being released a few minutes later? I understand that you have backtested for 10 years. But, have you really sit and think for a bit if you’re looking for entry at that time, the spread is getting widen that time and might not be a good idea to look for entry as there is a high chance that you get a slippage, very high chance. I would say that it is not doable unless you’re one of the large player who can move the market.

Sorry again. But, I think this is something to think about. When backtesting, you must put into consideration of what actually happened during it was live. And again, which I always say in the forum that I am not a fan of backtesting. To me, forward testing is the way to go.

Anyway, I wish you good luck in automating your trading strategy. Cheers.

Thank you both for your quick answers. As a matter of fact, I’ve kinda forgot about slippage, and did not really take it into consideration. From your experience, how bad can slippage actually be? The strategy in question clears around 25 pips per trade in average, so I tought I could afford to loose a few pips due to slippage issues. Do you think bad slippage could actually eat up all this profit, and lead to a negative average trade value? For the spreads, I tought of using a broker wich uses fixed spreads, to avoid spreads that widen up like crazy. I remember that requotes can also occur, wich could be another problem. Do you think the edge that I found could still be profitable after slippage and requotes? Thanks for your precious advice.

Slippage around news events can certainly be both huge and unpredictable.

But the main problem with “trading the news” is that your stop-loss may not be honored by the broker. :open_mouth:

I’m biased. I don’t trade the news.

I don’t know anyone who still does, though I know plenty of people who used to!

My experience is that absolutely everyone sooner or later has an absolutely “unforeseeable” accident from doing this and changes their mind about it.

And the fact that it’s the commonest single cause of account-loss really is just factual.

3 Likes

You can ask ChatGPT or DeepSeek (other AIs are available) to code it for you, just be very specific as to what you want.

It may take some back and forth but you should get there in the end, sometimes I use one AI to debug another’s code!

I would be careful with this in real life as the spread around news times can be very large and may mean the strategy isn’t profitable, not sure if backtesting would replicate this.

2 Likes

I too am looking at coding a news trading strategy.

I hate vibe coding, it’s a terrible practice! Learn the language and understand the code, this is potentially going to be spending your money, do not trust AI to do a good job.

I’m not saying don’t use it, but don’t blindly trust that the code it puts out will do what you expect it too. If you don’t understand the code, fixing or tweaking it becomes a mammoth task.

1 Like

First let me reply to your question. I highly advice that you don’t automate your strategy especially since you are scalping. What I advice you should do is to create an EA that will automate your pre-determined Stop Loss and Take Profit( Risk Management). This will enable you to enter and exit a trade with predetermined parameters since scalping requires fast fingers. Even traders that trade with automated strategies monitor them. So this is your best option. As for the slippage and requotes other traders are talking about, which are two similar things I suggest you take these factors into account in your back testing and then decide there from the results. But I think requotes should not be a problem as long as you are sure the news will move the market. As we like to say if you’re using a stop loss especially as a scalper or a day trader then you are already on the losing side of the market. But if you firmly believe that the market will move in your expected direction then you should do just fine. Slippage is another thing so you might want to maybe use other form of orders instead of instant execution, but again that brings up another challenge because then you have to be real sure that the price will make a pullback before heading in the original direction. Else you might just watch price move without you. Just keep practicing! soon everything will unfold for you :heavy_check_mark: