June 19


Stepping into Algorithmic Trading: A Beginner’s Guide

By Jeff Swanson

June 19, 2023

Algorithmic Trading, beginner, TradeStation

Discover the world of algorithmic trading. This comprehensive guide introduces EasyLanguage, explains the benefits and challenges of algo trading, and provides a practical example. Ideal for beginners.


The world is changing. You can see that all around you. 

From augmented reality to trading, things are changing. Fading from our world are the days when trading involved waking up early, coffee in hand, and closely watching the ticker tape roll by. Today, we're stepping into the exciting and high-paced world of algorithmic trading, where machines, not people, make decisions.

In this article, our focus will be to unravel the complex threads of algorithmic trading, explore its advantages and contrast it with traditional, human-driven discretionary trading. While the topic may seem daunting, we'll make it as accessible as possible. We aim to strip away the intimidating jargon and replace it with relatable explanations, always maintaining the gravity of our subject matter. We will also provide a tangible example to illuminate further the concepts involved.

So, if you’ve been considering algorithmic trading but are unsure what it is, I invite you to join us on this enlightening journey into the cutting-edge world of algo trading. 

What is Algorithmic Trading?

Algo Trading Is Trading With Rules You Give To A Computer.

Algo Trading Is Trading With Rules You Give To A Computer.

Trading is a vast world with different approaches to deciding when to buy or sell. At the heart of it all, we find two methods:

  1. Discretionary trading
  2. Algorithmic trading

Discretionary Trading

Not long ago, most traders were into discretionary trading. Discretionary trading is the old-school style where human intuition, experience, and judgment call the shots. Discretionary traders analyze market conditions, trends, and other factors, then make decisions based on their analysis.

Discretionary trading is like your grandma's secret cooking style—no recipe needed. It’s all about intuition, expertise, and judgment. As a discretionary trader, you analyze market conditions, trends, and other vital factors and then decide based on your findings. It’s an art requiring a refined palette honed over time. And for many, the results can be as satisfying as a well-cooked meal.

With the advent of computer technology and the ability of more and more people to utilize that technology, computers began to be used in trading. First, they were used to draw price charts of the movement of stocks. The technical indicators, like moving averages, were plotted on those charts. Ultimately, these computers evolved to make trades by simply buying and selling programs running on these computers.

Thus, we now have algorithmic trading. 

Algorithmic Trading

Imagine you have a smart kitchen appliance that knows exactly when to add the right ingredients to make your meal perfect every time—that's algorithmic cooking! When it comes to trading, you have a set of pre-programmed instructions, the system analyzes market conditions and makes trades with mathematical precision, all without human intervention.

Algorithmic Trading always hinges on rules. Think of these rules. These rules explicitly tell you when to enter and exit a trade. These rules might seem arbitrary or even chaotic at times, but they are there, steering your trades even if you don't consciously acknowledge them.

Now, let's consider some instances.

  • You hear a TV pundit passionately advocating for a stock on CNBC. You jump in and make a purchase. Voila! There's a rule in action: "TV pundit advocates, I invest."
  • A YouTube video highlights an interesting setup on gold so you place your oder? Ther rule: "YouTube pundit advocates, I invest."
  • Or, perhaps you're utilizing technical indicators? "Sell short if the price exceeds a 20-period average and the RSI value dips below 20."

The beauty of trading is that it accommodates endless permutations of rules. However, in algo trading these these rules are systematically defined, rigidly followed, and immune to whims or personal biases, they pave the way for an algorithm.

What is an Algo?

So, what exactly is an 'algo'? It's simply a set of predetermined rules dictating when to buy, sell, enter, or exit. It can also incorporate guidelines for position sizing, handling bulk orders, risk management, and more. In essence, an algorithm is a well defined trading plan. This trading plan can be given to a computer to execute. The computer will follow this algorithm 100%. No changing the rules, moving the stop or exiting early. 

An algorithm or algo for short, is nothing but a set of instructions telling the computer all the rules needed to buy and sell. That's it. No room for gut feelings or personal judgement – it's all about consistency and precision.

An algorithmic trading strategy can be as simple or complex as you make it. Fancy a straightforward example? Here's a two-line strategy:

1. Go long when the two period RSI falls below 20.
2. Sell when the two period RSI rises above 50.

This is a simple algo that will buy and sell based upon the RSI indicator.

So, what's the secret sauce to successful algorithmic trading? It boils down to two vital ingredients:

1. Testability: Most algorithms can undergo historical testing, also known as backtesting. This provides a huge advantage, which I'll delve into later. This allows the trader to assess the strategy's viability before risking real money. Think how powerful that is! You can test your trading ideas to see if they will work or not before putting money on the line.

2. Consistency: Algorithms are like well-disciplined soldiers. They follow instructions to the letter, every single time. If an algo spots a long setup today, it'll prompt you to go long. If the same setup recurs tomorrow, it'll signal you to go long again. The algorithm doesn't care about market news, Federal Reserve sentiments, or even if Jim Cramer emphatically recommended a stock on his show - unless, of course, you've programmed it to consider such factors. The algorithm remains steadfast, consistently adhering to its rules."

Do I Need To Be A Computer Scientist To Algo Trade?

Contrary to what you might think, you don't need a computer science degree to get started with algorithmic trading. There are user-friendly trading platforms and coding languages designed for this purpose. For example, TradeStation's EasyLanguage is popular due to its simplicity and power. But it's not the only option out there—various platforms cater to different needs and skill levels.

The transition from discretionary to algorithmic trading has been a game-changer in the trading world. I remember the first time I heard about algo trading. It sounded like something out of a futuristic novel. Back when I was getting into trading, I made all the decisions on when to buy and sell. But today, all my active trading is done via computer. Having a computer execute my trades is as commonplace as using my smartphone. The fact that we have this type of technology on our desktops and trust machines to handle our money shows how far we've come.

But don't worry, this doesn't signal an imminent robot uprising. Instead, it shows us a new path to efficient and strategic trading.

Advantages of Algorithmic Trading

Algo Trading Has Many Advantages

Algo Trading Has Many Advantages

Now that we've introduced algorithmic trading, let's talk about what makes it great for active traders like you and me. 

Speed and Efficiency: In the trading world, a few seconds can make a massive difference. Humans bless our hearts, we just can't compete with computers regarding speed. Algorithmic trading systems can respond instantly to market changes and execute trades at the speed of light (well, maybe not literally, but you get the picture). This allows you to seize opportunities that would be impossible to catch manually.

Reduce Psychological Factors: Algorithmic trading helps eliminate those pesky emotional and psychological factors that come with trading. Let's face it, we humans can be a bit... emotional. We panic, we get greedy, we fear missing out. Thus, we have a difficult time sticking to our trading plan. In short, we make dumb mistakes that cost us dearly. But computers? They're as cool as a cucumber. An algorithm won't buy a stock just because it has a fear of missing out. It won't panic and sell everything at the first sign of trouble. It sticks to the plan, no matter what.

Backtest Strategies: Before you run your algorithm in real-time, you can test it with historical market data to see how it would have performed. Think of it as a 'time machine' that lets you see the results of your strategy without risking any actual money. Backtesting gives you confidence in your strategy and helps you refine it before letting it loose on the live market.

Always Ready: We've all had those days when we're just not feeling 100%. Maybe we're a bit under the weather, or perhaps the latest episode of our favorite show left us up all night in suspense. Either way, our trading decisions on those days might not be the best. But an algorithm? It doesn't have days off. It doesn't get tired, sick, or distracted. It consistently follows the trading plan, day in and day out.

Trade in Multiple Markets and Strategies: Now, I don't know about you, but I find it hard enough to keep track of my keys, let alone multiple markets at the same time. But for an algorithm, this is a walk in the park. It can monitor and trade numerous markets and assets concurrently, increasing your opportunities to profit. A computer can trade 20, 40, or even more charts at the same time. Can you do that? In a way, using a computer to trade so many different charts is a way to leverage your time, tallents, and opportunity.

So there you have it, the major advantages of algorithmic trading. But before you rush off to code your first trading algorithm, it's only fair we also talk about the downsides. After all, no system is perfect, and it's better to be aware of the potential pitfalls upfront."

Disadvantages of Algorithmic Trading

Algo Trading Is Not Perfect

Algo Trading Is Not Perfect

I've waxed lyrically about the wonders of algorithmic trading, but like anything in life, it's not without its challenges. I believe in giving you the full picture, so let's explore some disadvantages.

Learning Curve: You have to learn to code to be a good algorithmic trader. At least for now. This may not be easy for some. Spending months learning a programming language may not be fun for some, while others find it a fun and rewarding experience. You also have to become familiar with computers. Most people are, but you may have to dig deeper with backups, power supplies, routers, and other less common computer issues. 

Technical Difficulties and System Failures: Computers are fantastic tools, but they're not infallible. There could be bugs in your code, server issues, or internet connection problems. Imagine your algorithm going rogue right when you've stepped out for a lunch break! Because we’re not perfect, nor is technology, it’s crucial to monitor your systems and have a backup plan in place.

Over-optimization in Backtesting: Remember the backtesting feature I was so excited about earlier? Well, it has a dark side. It's possible to tweak your algorithm so much based on historical data that it becomes too perfect, too specialized. This might sound good, but it can make your strategy ineffective when new unforeseen market conditions arise. It's like training for a marathon by only running in perfect weather on a flat surface and then finding out the race day is stormy on hilly terrain. 

Lack of Adaptive Judgment for Market Changes: Algorithms follow a preset strategy and can lack the ability to adapt to sudden changes in the market. As smart as they are, they can't yet interpret news events, political changes, or sudden market shifts as a human might. For now, they still need us humans to tweak and adjust them in response to such changes. We also have tools at our disposal to help with that, but that’s a more advanced topic for a later day.

Remember, these downsides aren't there to scare you away from algo trading, but rather to prepare you. The key to successful algo trading is creating a sound strategy, backtesting extensively, monitoring your system, and being ready to adapt when necessary. It's like sailing - you need to prepare your ship, know your route, keep an eye on the weather, and always be ready to adjust your course as needed.

Algo Trading Does Not Eliminate Emotions From Trading

Algo Trading Does Not Remove All Emotions From Trading

Algo Trading Does Not Remove All Emotions From Trading

Algorithmic trading is often the perfect antidote to the emotional roller coaster that can come with manual trading. By letting pre-set rules dictate your trading decisions, you insulate yourself from the fear, greed, and other emotions that can cloud your judgment. But let's not get too ahead of ourselves. While algorithms help steer the ship steadily through the turbulent market waters, they don't wholly banish human emotion from the equation.

How is that possible? After all, an algorithm doesn't have feelings. It doesn't second-guess its decisions or suffer from a fear of missing out. However, while the algorithm is emotionless, the person behind it isn't. Even the most seasoned algorithmic traders can fall prey to emotional pitfalls.

Firstly, there's the creation and tweaking of the algorithm itself. It requires discipline and objectivity to follow a rigorous development process, to backtest your strategy adequately, and to resist the urge to over-optimize based on past performance. The temptation to tweak the algorithm when it's going through a losing streak can be powerful—an emotional response that could lead to poor decisions.

Then, there's the trust factor. It takes tremendous confidence to trust your algorithm, especially during those inevitable periods of drawdown. Even with a tested and proven algorithm, doubt can creep in when the going gets tough. This can lead to manually overriding the algorithm, usually at the wrong time, and often leading to regrettable outcomes.

Lastly, there's the element of fear. Fear of missing out on a 'sure-win' trade that doesn't fit the algorithm's rules or fear of loss when the algorithm is underperforming. These fears can prompt rash actions, like abandoning your algorithm for manual trades or prematurely shutting down the algorithm.

Remember, while algo trading reduces the influence of human emotion in trading decisions, it doesn't eliminate it entirely. The key to successful algorithmic trading is acknowledging these emotional challenges and developing strategies to manage them effectively. After all, even the best algorithms are only as good as the trader's ability to stick with them.

Algo Trading Is Not “Set And Forget”

If you're new to the world of algorithmic trading, it might be tempting to think of it as a "set it and forget it" operation. You might imagine turning on your algo Monday morning and walking away only to check your account balance at the end of the week. However, issues can come up. Successful algo trading requires an attentive eye and an understanding of the technical issues that may arise.

Algorithmic trading, while heavily automated, is not immune to technical glitches. Machines may not experience fear or greed, but they can and do experience downtime, bugs, and data errors. It's essential to actively monitor your trades to ensure your algorithm is functioning as expected and to troubleshoot any issues that might come up.

Here are some common technical challenges you might encounter in your algo trading journey:

1. Connection Interruptions: In the digital world, steady internet connection is a trader's lifeline. A brief interruption can lead to missed trades or, worse, leaving positions open that should have been closed. Some algo traders opt for Virtual Private Servers (VPS) to maintain a steady, reliable connection.

2. Platform or Software Bugs: Even the best trading platforms are not immune to the occasional software bug. These could lead to errant trades, inaccurate data, or sudden crashes.

3. Data Feed Errors: Algos depend on real-time data feeds to make their decisions. If there's a glitch in this feed, the algorithm could make trades based on faulty data.

4. Hardware Failures: Computers, like any piece of machinery, are subject to failure. A sudden crash could leave your algo in the lurch, which could be catastrophic if it happens at a crucial trading moment.

5. Algorithm Errors: Sometimes, the problem lies within the algorithm itself. A coding error or an unforeseen scenario could lead to unexpected trading behavior.

So, while the automation in algorithmic trading alleviates much of the manual workload, it's not a hands-off approach. Just as a ship's captain keeps an eye on the horizon even in calm waters, an algo trader must monitor their systems, ready to steer through any sudden storms that might arise. After all, the market never sleeps, and while your algo might run like clockwork, it's up to you to keep the gears well-oiled.

I often check my trading algos several times a day. The vast bulk of the time, everything is running fine. But it's exceptions you want to catch!

Backtesting - A Time Machine For The Markets!

Backtesting a strategy is like a Time Machine!

Backtesting a strategy is like a Time Machine!

Imagine if you could peer into the past, armed with the knowledge you have today. Think of the power it would give you—the ability to see how a particular decision might have played out, to learn from your past mistakes before you even make them. Sounds like a dream, right? Well, in algorithmic trading, it's not a dream but a reality. We call it 'backtesting'.

Backtesting is the process of testing your algorithm's rules against historical market data. It's akin to a simulation, placing you in the thick of past market scenarios and enabling you to observe how your strategy would have performed.

The advantages of backtesting are manifold, but here are a few that really make it shine:

1. Risk Assessment: Backtesting allows you to gauge the level of risk associated with your strategy. You can see the drawdowns, the losing streaks, and the volatility, helping you set appropriate risk parameters.

2. Performance Evaluation: It provides a quantitative measure of your strategy's performance. You can evaluate key metrics like the Sharpe ratio, the win rate, and the average profit per trade.

3. Strategy Refinement: Backtesting shines a light on the strengths and weaknesses of your strategy. This insight allows you to fine-tune your rules, improving your algorithm over time.

4. Confidence Building: Knowing your strategy has weathered the storms of past market scenarios can build confidence in its future performance.

Now, to effectively backtest, you need the right tools. And that's where TradeStation comes in. It's my platform of choice, and not just because it has an impressive array of tools for algorithmic trading. Its backtesting capabilities are exceptional.

TradeStation allows you to backtest using precise historical data across numerous markets and time frames. It also offers an impressive array of performance metrics and customizable reports that let you dive deep into your strategy's performance.

The platform also boasts an intuitive interface that's friendly to beginners, yet powerful enough for seasoned traders. And let's not forget about EasyLanguage, TradeStation's proprietary coding language, which makes algorithm design accessible even to those without extensive coding experience.

In short, backtesting is an incredible tool in an algo trader's arsenal, and with a platform like TradeStation, you can leverage it to its full potential. Just remember, while backtesting offers valuable insights, it's not a guarantee of future success. Use it as one of many tools in your toolbox to navigate the thrilling journey that is algorithmic trading.

A Real-world Example of Algorithmic Trading

Now, let's bring all of this to life with a practical example of algorithmic trading in action. For this, we'll use a simple RSI indicator applied to the E-mini S&P. 

1. Buy Signal: The RSI value falls below 20, our algorithm would automatically place a buy order.

2. Sell Signal: When the RSI value rises above 80, our algorithm would then automatically place a sell order.

3. Filter: We're also going to create a filter. We only want to trade when the market is win a bull market. We'll define a bull market when price is above the 200-day simple moving average. This filter will supersede the Buy and Sell signals. That is, if we're in a bear market, no trading will take place.

4. Stop Loss: We'll also place a stop order $3,500 below our entry price. This will help protect our capital of the markets move against us.

Below is what the EasyLanguage code looks like. Don't worry if you don't understand the code. The point is, it's not a lot of code.



If ( RegimeLookback > 0 ) then
   Bullmarket = Close > average( Close, RegimeLookback )
   Bullmarket = true;

If RSI(close,2) < BuyThreshold and Bullmarket then
   buy next bar at market;
If RSI(close,2) > SellThreshold then
   sell next bar at market;

if ( StopLoss$ > 0 ) then
   Setstoploss( StopLoss$ );

This simple strategy applied to E-mini S&P produces these results, below. That's a $81,750 in profit. It's not super great but it's positive. You can see how a few simple rules can produce good results.

RSI(2) Strategy Example

RSI(2) Strategy Example

Remember, the devil is in the details. Fine-tuning your strategy, backtesting it thoroughly, and continuously monitoring it is where the real work (and fun) lies!

Why EasyLanguage?

EasyLanguage Is A Great Programming Language For Algo Traders!

EasyLanguage Is A Great Programming Language For Algo Traders!

Now, I know what you're thinking. 'Okay, Jeff, this all sounds great, but how do I actually start coding my trading algorithm?' That's where EasyLanguage comes in. It's a programming language developed by TradeStation specifically for designing trading strategies, and as its name suggests, it's... well, easy!

EasyLanguage was designed with traders in mind, not computer scientists. It uses simple, English-like syntax, making it more accessible for beginners than many other programming languages. Imagine being able to tell your computer to buy when the short moving average crosses above the long moving average, and it actually understands you. That's EasyLanguage for you!

What makes EasyLanguage stand out is its simplicity and focus on trading. It's specifically built for creating and testing trading strategies, so it has many built-in functions and features that cater directly to traders. This saves you time and effort as you don't need to code everything from scratch.

For new algo traders, EasyLanguage is a great tool because it allows you to focus on your trading strategy rather than getting lost in complicated programming syntax. But don't let its simplicity fool you. EasyLanguage is powerful and flexible enough to handle complex strategies and indicators. As you become more comfortable with it, it can accommodate the growth and evolution of your trading skills.

EasyLanguage is supported by a robust community of traders and developers who share code, answer questions, and provide resources. So, if you ever feel stuck or need inspiration, there's a whole community ready to lend a hand.

In short, EasyLanguage offers the perfect balance between simplicity for beginners and power for advanced users. It's like a trusty pocket knife - easy to handle, yet capable of getting the job done. So, if you're eager to dive into the world of algo trading, EasyLanguage is a fantastic place to start your journey.

Choosing Your Algo Trading Platform

When I first started looking into algo trading in 2009, TradeStation was about the only platform available. At least the only platform that could backtest and run algos I can remember. In short, it was King.Today you'll see a marketplace buzzing with various high-quality trading platforms. It's a competitive environment driving up standards and bringing better features and lower costs for the retail trader.However, navigating through these choices can feel overwhelming. Which platform is the best? Which offers the features you need? Which one simplifies the process of building algorithms? To help you cut through the noise, let's focus on some essential features that a platform should have for effective algo trading. Here's what you should look out for:1. Charting Capabilities: During the idea creation phase, it's crucial to visualize your concepts in action. A platform with advanced charting capabilities can make this much easier.2. Broker Integration: Platforms differ in their approach to broker integration. Some, like TradeStation, are linked directly to a specific brokerage, while others, like NinjaTrader or Multicharts, offer a wider selection. Consider the trade-off between convenience and options.3. Ease of Programming: An essential feature for algo traders is the ability to easily create custom indicators and strategies. A platform that offers an easy-to-learn programming language will be an asset in the long run.4. Market Data Integration: Ensure your chosen platform connects seamlessly with your required market data.5. Standard Indicators and Studies: Look for platforms offering a broad range of pre-programmed indicators and functions.6. Optimization and Walkforward Analysis: The platform should allow for optimizing your code's parameters and numbers. Additionally, the availability of walk-forward testing can generate more realistic "out-of-sample" results.7. Monte Carlo Testing: The platform should also have Monte Carlo testing to help you plan for possible future profits and drawdowns.

8. Trading Simulator The platform allow you to trade in simulation mode. This allows you to test your trading system on live market data without placing real orders.8. Trader Community: An active trading community can offer valuable insights and solutions. It's a significant plus when choosing a platform.9 Live Trading & Automation: The platform should cater to the entire process from development and testing to live trading and automation.TradeStation emerged as the clear favorite among my traders. Still, depending on your specific needs, any powerful platform might suffice. Here are the top contenders.

Top Choice:

TradeStation - TradeStation is a great platform. It's also my data provider and broker. And with its built-in programming language (EasyLanguage), it's the fastest platform to download and get up and running as an algo trader.

Other Great Platforms:

Remember, the perfect platform aligns with your trading goals and style, making your journey into algo trading as smooth and productive as possible.


And there we have it, folks! We've taken a deep dive into the world of algorithmic trading, compared it with discretionary trading, and explored the potential benefits and challenges of the algo approach. 

Remember, at its core, algorithmic trading is about consistency, speed, and emotionless execution. It's like a diligent worker bee, following your trading instructions to the letter, day in and day out. While it's not without its challenges - technical hiccups, the risk of over-optimization, and a learning curve - the potential advantages are certainly compelling. Faster trades, elimination of emotional decisions, and the ability to backtest are just a few perks that make algo trading appealing to many traders.

As we've discussed, getting started with algo trading doesn't have to be daunting, especially with the help of EasyLanguage. Its user-friendly syntax and robust trading-focused functionality make it a superb entry point for budding algo traders. And remember, there's a whole community out there ready to support you on your journey.

So, I encourage you to roll up your sleeves and delve deeper into algo trading and EasyLanguage. Start simple, take it one step at a time, and don't be afraid to get your hands dirty. The world of algorithmic trading is full of opportunities for those willing to learn.

Before I sign off, here's a fun fact for you to chew on: Did you know that as of my last check, more than 75% of trades on the US stock market are executed by algorithms? Now, isn't that food for thought?

Remember, trading, whether discretionary or algorithmic, is a journey, not a destination. So buckle up, enjoy the ride, and let's master EasyLanguage together!

Next Steps

In my opinion, if you want to become a successful algo trader, your first step is to learn a programming language. I recommend using TradeStation’s EasyLanguage. You can learn more by checking out these articles.

You can also find a lot of great EasyLanguage resournces on our Learn EasyLanguage page including, EasyLanguage Resource Page, EasyLanguage Quiz and Free Mini Course.

You can also have me teach you EasyLanguage by joining the Coder Edition of my System Development Master Class. That’s the fastest way to learn EasyLanguage. And time is money!

Jeff Swanson

About the author

Jeff has built and traded automated trading systems for the futures markets since 2008. He is the creator of the online courses System Development Master Class and Alpha Compass. Jeff is also the founder of EasyLanguage Mastery - a website and mission to empower the EasyLanguage trader with the proper knowledge and tools to become a profitable trader.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Learn To Code & Build Strategies
Using EasyLanguage.