Mastodon

Here’s What Went Wrong With My Trading Bot (And How I Fixed It)

Last Updated 09/20/26

Disclosure: This post may contain affiliate or referral links. If you sign up for a platform or tool through our links, we may earn a commission at no extra cost to you.

When you build something and put real money behind it, you find trading bot problems fast.

Not theoretical problems. Not “what if” scenarios you game out on a whiteboard. Real problems that cost real money, or very nearly do, and force you to fix things the same afternoon they show up. The first few weeks of live trading taught me more about my bot than all the testing that came before it combined, and almost none of what they taught me was flattering.

In this post I am going to walk through what went wrong, what I learned, and what changed because of it. I know I mentioned that results were coming in this post. I am going to push that back, because the honest truth is the bot was not ready, and publishing numbers from a system I was still actively repairing would have been telling you a story instead of the truth. So here is the truth instead: five specific things that broke, and exactly how I fixed each one.

The Bot Killed a Winning Trade

This one hurt, and it is the one I think about most.

The bot found a legitimate breakout. Volume was there, the trend was there, everything I had built the system to look for lined up cleanly. It bought in, and the stock ran, up sharply in about an hour. A textbook trade, the kind you build a bot to catch in the first place.

Then it sold.

The stock had paused for a few minutes. Nothing dramatic, just a normal consolidation after a strong move. Buyers taking a little profit, price drifting sideways for a moment to catch its breath. The kind of pause that happens inside almost every real breakout, the completely ordinary thing a chart does between one leg up and the next.

But the bot had an exit rule that was too sensitive. It saw a small dip in one of the momentum indicators, interpreted it as weakness, and triggered an emergency exit. Trade closed. The stock was still up. The breakout was still intact. Volume was still elevated. The bot had panicked over normal price action and locked in a tiny gain on a trade that had plenty of room left to run. Watching the stock continue higher after my bot had bailed on it was a special kind of frustrating, because nothing had actually gone wrong with the trade. The only thing that failed was my own rule.

The Fix

The exit rule was designed as an emergency valve, a genuine last resort for the rare case where momentum truly collapses. That part of the logic was right. The problem was the threshold. I had set it so close to normal trading behavior that it was firing on routine pullbacks, treating every ordinary breath the stock took as a crisis.

I widened the threshold so it only fires on actual weakness, not on consolidation. The trailing stop now handles the normal exits, the everyday job of walking a position out the door when the trend genuinely turns. The emergency valve is reserved for emergencies, which is what it was always supposed to be. The lesson underneath the fix is one I keep relearning: a safety mechanism that triggers too easily is not extra safety, it is a new way to lose.

Stops Weren’t Moving Fast Enough

That same trade quietly revealed a second problem, one that could have been far more expensive than the first.

The stock had run up sharply, but the stop was still sitting well below the entry price. If the stock had reversed hard right then, the bot would have given back the entire gain and then some, riding it all the way down to a stop that had never moved up to protect the profit. The gain was real on the screen, but it was completely unprotected, which means it was not really a gain at all yet.

The stop management system was updating on a slow, fixed schedule. That had seemed perfectly reasonable when I designed it. But breakouts do not move on a fixed schedule. A stock can run several percent in minutes and reverse just as fast, and thirty minutes is an eternity to wait when a winning trade is sitting there exposed and could evaporate before the next scheduled update ever arrives.

The Fix

I changed the stop updater to run far more frequently. The system now ratchets the stop up quickly once a trade starts moving, and the first priority is always the same one: get the stop to breakeven as fast as possible. Protect the capital first, then let the winner run. In that order, every time, no exceptions.

It reads like a small change on paper. In practice it is the entire difference between locking in a gain and watching it disappear. This is the same lesson that nearly cost me far more in a different situation, the one I wrote about in Part 2 of the bumps-and-bruises series, where the thing meant to protect my positions was, for a few minutes, not able to protect anything at all. Protection you have not actively verified is protection you do not really have.

The Scoring System Had a Blind Spot

This one took much longer to figure out, because on the surface the scoring system looked like it was working perfectly. Stocks with high scores were genuinely showing strong momentum signals. The math was correct. Nothing was throwing an error. Everything looked healthy, which, if you have read anything else I have written, you know is exactly the condition I have learned to distrust.

But the timing was wrong.

The system was scoring stocks based on momentum factors: how much they had moved, how fast, how much volume was behind the move. Higher score, better candidate. It sounds completely logical, and that is what made it so hard to see the flaw.

The problem is that by the time a stock has posted a massive move on heavy volume with stretched momentum, the best part of the move is very often already over. The bot was scoring the aftermath of a breakout, not the beginning of one. It was handing its highest marks to stocks that had already done the exciting part, and lower marks to the stocks that were just getting started. Some of the best setups of the week scored only modestly, precisely because they were early. They had not exploded yet. That is exactly the moment you want to be buying, and my scoring system was ranking those quiet early movers below the ones that had already run.

The Fix

I started stripping out the factors that rewarded late entries and over-weighted raw momentum without any context for where the move was in its life cycle. The goal shifted from “find what just moved the most” to “find what is about to move,” which is a much harder question and a much more valuable one.

That is an ongoing process, and I will be honest that it is not finished. The scoring system is still evolving and it probably always will be, because the market keeps changing the definition of a good setup. But the principle behind the fix is clear and it does not change: you want to catch the move early, not chase it late. A system that only recognizes strength after strength is obvious is a system that is always a step behind.

The Temptation to Lower the Bar

Some of the hardest problems were not in the code at all. They were in me.

During quiet stretches, the days where the bot scanned everything and found nothing worth buying, the urge to tweak things was constant and surprisingly strong. Maybe the criteria are too strict. Maybe I should loosen just one threshold. Maybe if I adjust this single parameter the bot will start finding setups again and I will feel productive instead of stuck.

That is a trap, and it has a name. Loosening your criteria to manufacture trades during unfavorable conditions is a form of overfitting: you quietly optimize the system for what just happened, and the moment conditions change you are worse off than you were before you started fiddling. You will have traded a system that waits patiently for a system that chases, and the market punishes chasing.

The bot was not broken during those quiet periods. The market simply was not offering what the system was built to look for, and the correct response to that is not to lower your standards. It is to wait. So I left the criteria alone, which was much harder than changing them would have been, because doing nothing feels like failing even when it is exactly right. When conditions finally shifted and momentum returned to the market, the bot found real setups again, and they were better setups than anything it would have taken during the dry spell. The discipline paid for itself the first good week after.

Sometimes the Human Has to Step In

One day I had a position up enormously in a single session. A parabolic move, the kind that makes for a great screenshot and a genuinely terrible overnight hold.

The trailing stop system, left to its own logic, would have held the position through the close. If the stock gapped down at the open the next morning, the stop would have caught it, but at a much lower level than where it sat that afternoon. If it gapped up, the ride would have continued. The system was doing exactly what I built it to do.

I sold it manually anyway.

That was not a failure of the system, and I want to be clear about that, because it would be easy to read it as one. It was recognizing that an enormous, vertical, single-day move sits outside the range of conditions the system was actually designed to handle. The trailing stop tiers were built for normal trends, for the ordinary rhythm of a stock trending up over days. They were never built for a rocket. Sometimes the operator can see context that the algorithm simply cannot, and acting on that context is not cheating. It is the job.

The best automated systems still have a human layer that knows when to engage and, just as importantly, when to leave the machine alone. Most days the right move is to trust the system and keep your hands off it. But knowing the difference between most days and the rare exception is a skill, and it is one you only build by paying close attention.

The Pattern Behind Every Fix

Line these five up next to each other and a single pattern jumps out, the same one every time.

In each case, a rule that made perfect sense in theory did not survive contact with live conditions. The emergency exit made sense until it fired on a normal pause. The fixed stop schedule made sense until a stock moved faster than the schedule. The momentum scoring made sense until it started grading the end of the move instead of the start. Even my own discipline made sense until a quiet market tempted me to abandon it. None of these were failures of logic. They were failures of calibration, of a reasonable idea meeting an unreasonable reality and needing to be adjusted against it.

And crucially, the fix was never to throw the rule away. It was to calibrate the rule against reality: give the exit signal more room, give the stop more speed, give the scoring better timing, give the operator clear rules about when to step in. The instinct when something goes wrong is to rip it out and replace it. Almost every time, the better move was to keep the idea and fix the number.

None of these problems were catastrophic, and that is not luck. The system protected capital through every one of them, because the risk management underneath was solid even when the layers on top were miscalibrated. That is the whole argument for building the safety net first, the same conclusion I keep arriving at from every direction, including in the smaller mistakes I catalogued in Part 1. Get the thing that protects your money right, and everything else becomes a problem you can survive long enough to fix.

What I’d Check First If You’re Debugging Your Own Bot

If you are building something like this and staring at behavior you do not understand, here is where I would point you first, based on the afternoons these problems cost me.

Look at your exits before your entries. Almost everyone, myself very much included, pours their attention into the buy logic and treats the sell logic as an afterthought. But four of the five problems above lived on the exit and risk-management side of the system, not the entry side. That is not a coincidence. The entry decides which trade you are in. Everything that determines whether you keep the money happens after.

Distrust the parts that look healthy. The scoring blind spot survived the longest precisely because nothing about it looked broken. A crash announces itself. A miscalibrated rule that quietly does the wrong thing while reporting success will sit in your system for weeks. When something feels subtly off about your results even though nothing is erroring, believe the feeling and go digging.

And watch yourself as closely as you watch the code. The overfitting temptation and the parabolic-exit call were both about the operator, not the algorithm. Your own impatience during a slow week is a bug in the system too, and it is the hardest one to catch because you are the one inspecting it.

Finally, keep a written record of every change and why you made it. Each of the fixes above started as a single confusing trade, and the only reason I could trace them back to a specific rule was that I could go look at exactly what the bot saw and did in that moment. Without that record you are debugging from memory, and memory is a liar, especially about the trades that cost you something. Write down the symptom, the diagnosis, and the change, because the same class of problem will show up again in a slightly different costume, and the notes you take today are the shortcut you will be grateful for the next time a trade does something you cannot immediately explain.

Up Next

In my next post I stepped back from the technical side to talk about what I would actually do differently if I were starting this whole project from scratch today, the things I would skip, the things I would do far sooner, and the stuff I wish someone had told me before I wrote the first line of code. If you want that bigger-picture version, it is all in what I’d do differently if I started over. And if you are earlier than that, at the very beginning and wondering how any of this gets stood up in the first place, here is exactly how I would set up a Robinhood trading bot from scratch.

Performance numbers are still coming, once there is enough data to say something that actually means something instead of cherry-picking a good stretch. Right now the focus is on getting the system right, because the numbers do not matter if the process underneath them is broken. Every one of these trading bot problems made the system tougher and the rules smarter, and that is the trade I will take every time.

If you want to follow along, the article library has the whole build in order.

Steve is the founder of Bot and Bull. He reviews and evaluates the tools featured on this site and only recommends what he genuinely believes in. No press releases, no paid placements.


Found Bot and Bull useful? A quick review helps others decide whether this site is worth their time, and it takes about a minute. Review us on SmartCustomer →


Disclaimer: Everything in this post is shared for educational and informational purposes only and is not financial, investment, or trading advice. I am not a licensed financial advisor, broker, or tax professional. Automated trading carries real risk, including the possible loss of your capital, and the tools or platforms mentioned may not be suitable for your situation. Do your own research, and consider speaking with a licensed professional, before making any financial decision.

Leave a Comment