Episode Overview

What to look out for when creating a trading system through TD Ameritrade’s Thinkscript or any any trading system for that matter. Ryan talks about the most important aspect of any trading system and steps that one can create to maximize the profitability and minimizing the massive drawdowns often associated with trading systems.

🎧 Listen Now:

Available on: Apple Podcasts | Spotify | Amazon | YouTube


Episode Highlights & Timestamps

  • [0:07] Introduction to Automated Trading
    Ryan kicks off the episode discussing the rise of automated trading and introduces the listener email from Reuben about building custom scripts for swing trading.
  • [1:53] ThinkScript and Pattern Recognition Tools
    Reuben explains his programming experience and desire to write scripts to improve trade execution. Ryan shares his experience with ThinkScript and alternatives like TrendSpider.
  • [6:36] The Rumsfeld Principle for Traders
    Ryan uses a quote from Donald Rumsfeld to introduce the concepts of “known unknowns” and “unknown unknowns” in market risk, and how these affect automated strategies.
  • [9:19] The Importance of Drawdowns
    A detailed explanation of how drawdowns define a system’s resilience. Ryan emphasizes that win rates are meaningless without solid risk management.
  • [12:59] Fail-Safe Mechanisms and Flash Crashes
    Ryan gives real-world analogies (like boat safety cords) to illustrate the need for robust failsafe triggers in your automated system, especially during events like COVID-19 or the 2010 flash crash.

Key Takeaways from This Episode:

  • Drawdown Management Is Crucial: A high win rate doesn’t matter if your system can’t survive market downturns or black swan events.
  • Most Systems Work in Bull Markets: Many strategies look great in strong uptrends, but few can handle sideways or bear markets effectively.
  • You Need a Fail-Safe Trigger: Just like a boat’s emergency kill switch, your system must shut down bad trades before they spiral.
  • Pattern Recognition May Already Exist: Platforms like TrendSpider offer robust pattern tools. Build custom scripts only when you have a unique edge.
  • Emotion Removal Is a Double-Edged Sword: Automation can help reduce emotions, but it requires intense upfront discipline in risk and trade management rules.

Free Swing Trading Resources

Take the Next Step:

Stay Connected: Subscribe to Ryan’s newsletter to get free access to Ryan’s Swing Trading Resource Library, along with receiving actionable swing trading strategies and risk management tips delivered straight to your inbox.

📈 Level Up Your Trading: Ready for structured training? Enroll in Ryan’s Swing Trading Mastery Course, The Self-Made Trader, and get the complete trading course, from the foundational elements of trading to advanced setups and profitable strategies.

📲 Join the Trading Community: Sign up for SharePlanner’s Trading Block to become part of Ryan’s swing-trading community, which includes all of Ryan’s real-time swing trades and live market analysis.


Full Episode Transcript

Click here to read the full transcript

0:07
Hey, I’m Ryan Mallory. And this is my swing trading the stock market podcast. I’m here to teach you how to trade in a complex ever-changing, world of Finance, learn what it means to trade, profitably and consistently managing risk, avoiding the pitfalls of trading. And most importantly, to let those winners run wild, you can succeed at the stock market and I’m ready to show you how, hey, everybody, this is Ryan Mallory with swing trading the stock market podcast.

0:35
Fast. And today’s episode, we’re going to be talking about automated trading, we’re talking about, writing your own scripts, for swing trading, and what are the pros and cons where it is? Some of the things that you want to keep in mind when you’re doing this. This is going to come from a guy. We’re going to call them Ruben. That is the name in which he asked to go by so always accommodate those requests.

0:54
Ruben rights. Hi right. I’ve been listening to your podcast now for about six months and I appreciate all you do. Feel free to call me, Reuben, for the purposes of the podcast for a while. I’ve been wanting to get into Swing trading for supplemental income. I work remotely full-time with a flexible schedule, so I would probably be doing a little bit of the trading in the mornings before work being an early riser in the Pacific time zone helps.

1:16
I just don’t want to give up that. Nice steady paycheck for those who don’t realize Stock Market opens up at 9:30 Eastern Standard Time. So, essentially over on the east coast Stock Market, opens up at 6:30, I’ve always kind of wondered, how would I deal with that? Because I’m on the east coast. And so I’ve never had to necessarily trade at 6:30 in the morning and I don’t know how I would do that.

1:37
I’m more of a night persons, but I mean, on the other side, it’s kind of nice that the stock markets closed at 1 p.m. so there’s some pros and cons there your day is done a whole lot earlier and you have a whole lot more left of your day, but that’s 6:00 in the morning thing that would be pretty tough to be ready to trade by then.

1:53
So any case room and goes on to write because of the nature of my work, I have a fair bit of experience with computer programming and so I’ve gotten very interested in writing. Think script studies using TD Ameritrade platform for your listeners who might not know? Script is a program based language built into thinkorswim.

2:08
I believe it can be used for analysis and even automating orders and sales. I’m curious if you know much about automated trading or custom studies like this. If so, do you have any advice on how you manage the risk, when executing trades automatically assuming you program it to stick to your trading plan or maybe, you know, of someone who else has tried using the things script and might have some insight.

2:29
I’m thinking of using this as a means to remove emotions from the equation as much as possible. I imagine that a strategy like this would need to be tested out in some way. Just like any other, it would need to be programmed to follow reward to risk ratio, stop loss placement and manageable position sizes. But I see that these scripts can be set to respond to certain chart, patterns, just like some people do manually with their own trading patterns to start out.

2:52
I may use it to automate opportunity and Discovery rather than automate the actual order placement. But I am curious about the potential for the latter as well. I don’t see writing trading scripts as a means to totally ignore my As I would certainly monitor it very closely. If I were to go with a strategy, I see it more as a tool to remove emotions or to get the timing better for certain desirable trade setups where I would probably be placing a manual order.

3:16
Anyways, also, I’d only be using it for stocks and ETFs and things like that. I’m not interested in Forex options or anything like that. If ever maybe I could even program it to take some profits along the way unfavorable trades. I know this subject might be a little niche but I figured it could make it.

3:35
Good podcast episode. Either way. Thanks for your time, Reuben.

3:40
Okay, Reuben. I appreciate that email. Well, written email to, by the way, I tend to notice good grammar man, guy writes pretty well, maybe he used chat GPT, you know, you never know. But there’s a lot to actually unpack on this email and I’m excited to dig into this first off.

3:54
I’ve got no issue with automated trading. I think so much of trading today. Anyways, is automated, you look at what you’re seeing in the stock market, it can really drive you nuts at how automated it is. For instance, we oftentimes think that Automated trading is very very sophisticated and if you do it long enough, you can even spot the automated trading that’s taken place like for instance, over the past, I would say last two or three months, almost every time, there’s a new intraday low that’s made, there is automated trading that comes in, where the buyers are buying ferociously, on every new intraday low practically and where you see it backfires when they initially pop the market a little bit and then all of a sudden, the sell orders come in and overwhelm them and they’re taking some major.

4:35
Losses, but I would say more times than not over the past couple months, they’ve gone away with it. And it’s been a decent strategy, but it’s only as good as its last and so you never know when it’s going to end. So you start to pick up on it and then when you finally start to pick up on it, that probably means that there’s a thousands if not millions of other people that are picking up on it, then it becomes a saturated trade strategy with no viable upside.

4:57
So, I have tinkered a little bit and I’ll use the word tinkered when it comes to using TD Ameritrade stinks because I never used it to automate Have played with the language a little bit and learned a little bit about it. It’s definitely something that you can learn. There is a learning curve to it, but if you apply yourself to it, I think most people can pick it up, but it’ll take some time now, automated trading.

5:18
There’s a lot to be said about this Ruben talks about how he would like for it to pick up on patterns. Well, the good thing is, there’s actually a lot of pattern recognition software out there already, but believe, TD, Ameritrade has it. I’ve seen it before. I don’t know if they still have it on their platform, but I’ve seen it on the TD Ameritrade platform before.

5:34
I don’t know if it’s All that great. But then there’s others like Trend spider that has a phenomenal pattern recognition platform. So that’s a really good one there that people can use. So you don’t necessarily have to write a new script. It’s kind of like Reinventing the wheel at that point.

5:49
If you’re just doing for pattern Discovery now the caveat to it might be as if there’s a pattern that only, you know, about or there, something that you’ve noticed in the market that other people aren’t picking up on that. You think is can be exploited for your benefit or your profit. So if that’s the case, then yeah, I would probably write my own script. I wouldn’t go tell him.

6:05
What about it? One thing I would be telling people about swing trading the stock market.com. Yes, I’m plugging a service here that’s in conjunction with this podcast with it. You’re going to get my stock market research each and every day that’s going to include my daily. Watch lists my weekly. Master updated watch list for both, bullish and bearish.

6:21
Stocks that I’m following throughout the week. Plus you’re going to get updates on the S&P 500 with video and same thing with the big tech stocks as I track daily and you’re going to get videos throughout the week of different trade ideas and opportunities. Cities that arise so check that out.

6:36
Swing trading the stock market.com, it’s great, you’re supporting the podcast in the process. Now, back to Ruben here. There was a book that I read. I want to say probably back in my college days because it was when George w–. Bush was president at the time. And I think Donald Rumsfeld was his secretary of defense.

6:55
Now, Don Rumsfeld kind of had an interesting career because when he first started off as Secretary of Defense, he was highly popular, he wrote a book called. I think the Rumsfeld way pulling this all from memory actually it’s the I’m shocked that Remember, the book table, but I read it and there was something he actually said it was quite profound. And it’s always stuck with me.

7:10
He talked about there being two things, one, and he was talking about more from like a war environment, but it applies in so many different areas of life. He talked about the known unknowns the things that you don’t know. But that, you know, that you don’t know, like that can be like, you know, the enemy is out there, but you don’t know exactly where they’re at. And then he said the ones that really get you is the unknown unknowns which would kind of be like, you don’t realize that there’s an enemy out there and you don’t know where they’re at.

7:33
And so I think when When you are putting together, your trading strategy, you know, and creating a trading script, whether it’s algorithmic trading or some kind of other automated form of trading, you want to be asking yourself these two things.

7:49
What are the known unknowns and what are the unknown unknowns? For instance, one of the things that really messes up, most of your trading systems and I would say this should be the biggest thought process when it goes into creating a trading system is The risk management now that probably doesn’t come as a surprise to most people.

8:09
Yes, that is extremely important. But then you extrapolate that a little bit further. What are the draw down? The draw Downs as what defines, which is part of risk management. Is what defines how successful or unsuccessful your trading systems going to be?

8:25
Because it can look like, hey, this system has a 75% win rate, it does great all the time I’ve seen in fact, trading systems with a 90% when rate and they’re still horrible. Be unprofitable because the risk management just isn’t there. And so the draw Downs are really what kills a good trading system.

8:44
Now, the no not, you know, there’s going to be pullbacks along the way. You know that even in a strong bull market, there’s going to be periods where you might go like, a few weeks or a couple months where the markets pulling back. That’s something that you want to see. Okay, am I going up 10% of my portfolio before every time? There’s a pullback pullback? 15% that’s something that you want to address. Do I need to tighten my stop loss? Has some do I need to figure out how to To minimize the risk while squeezing out more profits in the process. But the big one is the unknown unknown. And that’s like, your major Market events. The one of the best examples in recent times that I can think of, actually, I’ll give you two, but the first one is the covid crisis.

9:19
Do I mean, they shut down the entire economy. We essentially saw in just a matter of weeks spy go from like, 340 down to the low 200s and a matter of weeks, look how far we’ve dropped on the S p– over the course of the past year and a half and it’s nothing like what we saw during covid in that little couple week. In fact it’s footprint can be seen all over practically every chart out there. You look at a chart without even seeing the x-axis which tells you the time on a chart you can see we’re covid is on almost every chart. You look at, you can say that was covid right there because it’s pretty much all the same and that was a big unknown, unknown February.

9:54
Yes, people were talking about covid. Even in January, people were talking about it, but what people didn’t know yet was how it was going to impact the market. In fact, when covid started spreading in its early stages, the It was still going up, it wasn’t until they started shutting down the economy, 14 days, whatever it was to flatten the curve. They said, originally, and the market took an absolute beating. Now that would be a huge unknown unknown because I don’t think anybody on their bingo card had stock market, or spy going from 338 down to 215 or 218 whatever it was.

10:27
But at that was a massive dip and three weeks. And if you’re in a trading system, it might have been far worse. Because what if your risk management Mint, couldn’t react fast enough. And so, let’s say you had a trading system that was simply trading off a spy. Okay. That’s all you traded.

10:42
Your train specific patterns off, a spy and let’s say that the variable unsane do this. I’m just trying to essentially form fit like a worst-case scenario to what happened back in covid. But let’s say you had a stoploss like okay, after four weeks of negative returns or let’s just say a month of negative returns I’m going to exit spy.

11:00
Well let’s say that was applied to the whole cobit circumstance you go from 3:38 practically down the lake to 18 and you get stopped out. And then the market runs higher for the next year and a half. Actually I’d probably say for like the next 20 months. Could you imagine that be brutal?

11:16
You take like a massive loss 338 down to 218. I think I keep changing that bottom number. I just need to go ahead and look it up the bottom number was to 1826. Okay, so let’s say you get out of like 220, let’s assume you didn’t bottom, take the whole thing. Let’s say you got out at 220. So from 338 to 220, that’s a massive Of loss. And then you just see it just rip higher like by the end of the year, it’s trading at all-time highs again, that would be a really bad form of risk management. Now, I gave you kind of like the worst way to create a stop loss, but there’s probably people out there that have trading systems, that have horrible failsafe mechanisms and what our failsafe mechanism is, essentially something that a lot of the engineers will use in their designs are products when something goes, awry, boom.

11:58
You know, stop the machines, one of the best failsafe mechanisms that I can think of, in the real world. Not, the trading is not the real world. You know, is when I’m on a boat, if the captain or the driver gets thrown out of the boat, he usually has this little thing that’s wrapped around his wrist, a little cord, that’s connected to the engine to where if he gets ejected that pulls out of the driving console, and it shuts down the boat immediately, that would be a good Fail-Safe mechanism for boating, but we got to make sure we have a good Fail-Safe mechanism in our automated trading as well.

12:26
Because the last thing you want is like a really bad one in like, in the example that I just gave, that’s essentially like having a an ejection seat that shoots, its It up in the air after it’s already crashing, hit the ground. Doesn’t do you much good at that point? It’s just ejecting a dead body at that point.

12:42
And so we don’t want our trading system to react to an unknown unknown. A major Market risk after the fact, because if they would have done that during covid, that would have been a really bad thing. Same thing goes for like the fat finger flush that was back in, I think it was about May of 2010, the fat finger trade or whatever they called it.

12:59
But I remember watching it. The market essentially just drop like 1,000 points and back then the Dow which The thousand-point flush was just coming out of the recession, you know, recession had just bought him doubt back in 2009. So, you know, Dow, I think was trading probably around like, 12,000 in a flush, like a thousand points, that’s a big move, that would be essentially equivalent to a, like flushing about 3,000 points today, and it did it all in a matter of minutes and it was crazy.

13:23
And didn’t get popped right back up. Those are unknown unknowns, there will be unknown unknowns in the future and how will your system react to it? You have to have a way of avoiding massive draw downs and horrible trades. Taking place because of something that you didn’t account for. Yes, normal draw Downs are part of every trading system but you don’t want it to go belly-up on you, you don’t want to see your trading system capitulate, and that’s why I’m focusing so much of it on this particular podcast episode.

13:50
And here’s the other thing to remember, most of your trading systems tend to do fairly well and bull markets. I mean, there’s a time and there’s a place where people talked about like the.com era for instance, that a monkey could throw darts at a dartboard and beat the S&P. E. 500 because so many stocks were just ripping higher during that period of time, that you could actually trade very well.

14:11
Just by randomly choosing stocks, and there’s been times like that to like, I would probably say 2021 was like that, and it was frustrating for me as a traitor, because I always keep risking mine, right? But there are times in the market where almost anything goes up, and a lot of your trading systems, will do really good and look really good.

14:28
Following a strong bull market or a period where the market runs higher. I mean, take 2020 after the covid bottom. I would say most of your trade. Isn’t that phenomenal during 2020 after the covid bottom because the market was just ramping higher almost on a daily basis. But when you start to hit those draw Downs, how does it do then?

14:45
Because if it has a 50% pullback and your portfolio, guess what you got to do. You got to make 100% before you can even break, even or let’s say even worse, let’s say, you have a 75% pullback in. Yes, you can have a 75% drawdown in your account. Well then all of a sudden, you got to make 300% return just to break even and so you may not ever come back from that.

15:07
So you have to make sure that there is a Fail-Safe mechanism in your portfolio. How does it handle the draw down? These are the most important question because I don’t think it’s the hardest thing to come up with a strategy that does really well in the bull markets. But it’s much more difficult for that system to hold up under the pressure of a bear Market or even a natural pool back.

15:24
I had to investing system back in the day that I would use on a regular basis and essentially I had a 10% trailing stop loss on I don’t like trailing. Stop loss is one of the reasons why I Use them anymore. But I would use this trailing stop loss on all my trades and it would be like 10%.

15:40
And it would take advantage of stocks in the S&P 500 that had experienced a significant pullback that was extremely oversold and setting up for a bounce. Well, during some of these pullbacks you get, this is another thing, you’ve got to make sure of is that in a bull market, you wouldn’t get a ton of stocks that were pulling back all that much.

15:57
You would get few. And that was the ones that I really like, that’s when the system did its best, but then, if you had a pullback in, let’s say the market pullback. Sent, I think everything would be practically activating, then you have almost everything setting up and the trading system as a by.

16:17
And if you have like, 400 out of the 500, S&P 500 stocks qualifying for your trading system. During a market pull back, it’s going to be kind of hard to one manage, 400 stocks, but to also buy all of them without essentially, diluting your Capital. So you want to make sure to that, the conditions that your system takes advantage of that.

16:35
It’s not going to spit out more trading opportunities than what you can take advantage of because then it’s really not a tree. System you’re having to actually pick and choose which stocks you’re going to trade out of the ones that are qualifying to be bought. And if that’s happening, then you need to be a little bit more, stringent on your trading, requirements for your trading system.

16:57
Now that can also affect you though, to wear it almost reads out all of them during a bull market or during the conditions where you might not be getting as many stocks that qualify for your trading system.

17:10
In any case to wrap this up, make sure that you’re putting a lot of emphasis on draw Downs. Make sure you’re putting a lot of emphasis on unknown. Own unknown events and the market, for instance, like what we talked about with covid and with the flash crash from back in May of 2010, and then we talked about the Known Unknown, how’s your system going to handle earnings reports?

17:30
Are you going to hold it through? Well, you got to make sure that you put in that system. Hey, I don’t want to be holding a stock through the earnings reports that the day before, maybe even a couple days before. And I definitely don’t want to be buying stocks before earnings, those are questions that you want answered in your trading system.

17:35
And finally, what, what stocks would you prefer not to trade, there may be some stock that I do. Or how good of a signal. It’s providing. I do not want to trade those. And so you want to make sure that’s accounted for in your trading system as well.

17:50
So if you enjoyed this podcast, I would encourage you to five star review, on whatever platform. You’re listening to Spotify Apple, Google Amazon, there’s tons of them out there. I Heart Radio also, make sure to keep sending me your question. ryan@shareplanner.com. I read them all. I try to make an episode out at every single one that is Keef. If I haven’t done one, send it to me again. ryan@shareplanner.com. Thank you guys, and God bless.

18:06
Thanks for listening to my podcast. Swing trading the stock market. I like to encourage you to join me in this SharePlanner trading block, where I navigate the stock market. Each day with Traders from around the world with your membership, you will get a 7-Day trial and access to my trading room including alerts via text email and WhatsApp.

18:22
So go ahead, sign up by going to shareplanner.com trading block, that’s www.shareplanner.com/trading-block. And follow me on SharePlanners, Twitter, Instagram and Facebook where I provide unique Like market and trading information. Every day you have any questions, please feel free to email me at shareplanner.com all the best to you and I look forward to trading with you soon.


Enjoy this episode? Please leave a 5-star review and share your feedback! It helps others find the podcast and enables Ryan to produce more content that benefits the trading community.

Have a question or story to share? Email Ryan and your experience could be featured in an upcoming episode!


Become part of the Trading Block and get my trades, and learn how I manage them for consistent profits. With your subscription you will get my real-time trade setups via Discord and email, as well as become part of an incredibly helpful and knowledgeable community of traders to grow and learn with. If you’re not sure it is for you, don’t worry, because you get a Free 7-Day Trial. So Sign Up Today!
 

You Might Like

  • Fading the Gap: How Large Overnight Moves in SPY and QQQ Play Out During the Trading Day

  • How to Trade a Bear Flag

  • Technical Analysis vs Market Conditions: How to Know What’s Affecting Your Trades