Backtesting Articles & Tutorials - Trading Heroes https://www.tradingheroes.com/category/backtesting/ Discover Your Grail Trading Strategy Tue, 12 Aug 2025 23:08:53 +0000 en-US hourly 1 https://wordpress.org/?v=6.9.4 https://www.tradingheroes.com/wp-content/uploads/cropped-white-color-32x32.jpg Backtesting Articles & Tutorials - Trading Heroes https://www.tradingheroes.com/category/backtesting/ 32 32 The Ultimate Guide to TradingView Backtesting https://www.tradingheroes.com/backtest-in-tradingview/ Wed, 10 Jul 2024 01:59:11 +0000 https://www.tradingheroes.com/?p=1024647 TradingView makes it easy to backtest trading strategies. But there are things that you have to be aware of to get accurate results.

The post The Ultimate Guide to TradingView Backtesting appeared first on Trading Heroes.

]]>

When you buy something through one of the links on our site, we may earn an affiliate commission.

In this tutorial, I'll show you how to use the backtesting function in TradingView and give you the benefits and downsides of this platform, based on my personal experience.

This powerful tool allows traders to test the effectiveness of any trading strategy, whether it's one they have developed themselves, or one created by a member of the TradingView Community.

Key Takeaways

  • TradingView's backtesting function allows traders to quickly test a wide selection of trading strategies across a huge collection of worldwide trading markets.
  • The platform offers a variety of strategies created by Community members, as well as the ability to create your own.
  • While there can be limitations to TradingView's backtesting platform, there are also solutions.

Benefits of TradingView Backtesting

Trading at beach

Here are some of the benefits of using TradingView's backtesting platform:

  • Fast results: The backtesting system is fast, and you can see the results right away. This allows you to iterate quickly and adjust your strategy accordingly.
  • Community scripts: You can use other traders' strategies that are available in the Community. This saves you time and effort in developing your own strategy.
  • Historical Data: TradingView has a Deep Backtesting feature that provides all the historical data you need to conduct a thorough backtest.
  • Easy to use: The backtesting function is simple, no complex setups required.
  • Access tons of worldwide markets: TradingView gives traders access to a wide range of markets from around the world. It could be the largest collection of publicly available data feeds in the world.
  • Browser based: Available on almost any operating system.
  • Create your own strategies: Make and test your own strategies quickly with Pine Script.

Now that you know a little about the platform, here's how to start using it.

How to Access Strategy Tester on TradingView

First make sure that you're logged into a paid account.

To access the backtesting function, first click the Strategy Tester tab at the bottom of the screen.

Strategy Tester in TradingView

From there, click on the Load Your Strategy button.

This can either be a strategy that you've created or one that's been developed by a Community member within TradingView.

To find a strategy, search by name or browse through the available community scripts.

Be sure to use the menu on the left of the window to see other types of strategies.

Select Personal to see the strategies you've created.

TradingView Strategies

Yeah, there are a TON of strategies available and it can be a little overwhelming.

So start with something that you understand and test all the related strategies.

For example, when I search for a Bollinger Bands trading strategy, here's what comes up.

The number on the right of each strategy indicates the number of people currently using it.

Strategies list in TradingView

Usually, the most popular ones are at the top.

But not always.

So scroll through the strategies to see them all.

Once I click on a strategy, TradingView will add it to my chart, run the backtest on the current market/timeframe and give me the results.

Strategy result

You can see the trades it took and get a performance summary report below the chart.

Pretty slick!

How to Run the Backtest on Other Markets and Timeframes

Once you've selected a strategy to backtest, it's super easy to run the test on any market and timeframe available on TradingView.

To run the test on another timeframe, simply click one of the available timeframes on the top of the current chart.

You can even set your own custom timeframe by clicking on the down arrow and selecting “Add custom interval”.

Timeframes in TradingView

The results of the backtest on that timeframe will appear on the bottom of your screen, just like with the first backtest.

You'll see the results almost instantly, making this a very efficient way to backtest.

To test the strategy on other markets, click on the watchlist icon in the upper right corner, then click on the market you want to backtest.

TradingView backtest on new market

You can also click on the current market ticker in the upper left corner of the screen and search for a new market to test.

Search for market in TradingView

Again, as soon as you select the market, you'll see the backtesting results in the bottom panel.

Remove a Trading Strategy

To remove a strategy from your chart, click on the Object Tree icon on right side of the screen, then click the Delete icon next to the trading strategy.

Remove TradingView strategy

Once you've deleted a strategy, you can a new one, or go back to using TradingView as just a charting platform.

Evaluating Backtesting Results

Now it's important to talk about what a “good” backtesting result is.

Many new traders think that they need to have a fantastic result on the first try, or the backtest is a failure.

That's not how it works.

In reality, it's best to look for strategies that have potential.

So here are some things to look for:

  • The strategy is near breakeven: The strategy could be optimized
  • There are huge winners, which get slowly get taken out by small losers: The number of losers could possibly be reduced
  • Conversely, there are consistent small winners, but a few big losers: The size of the losing trades could be reduced
  • Strategies that perform well in some markets but not others: Only trade it in markets where it performs well

But that's just the tip of the iceberg.

To get a complete guide on how to judge and potentially improve backtesting results, read my article on good backtesting results.

Selecting a Trading Strategy the Smart Way

When it comes to selecting strategies to test, there are a couple of ways to approach it.

First, you can browse the available strategies that you can use for free, as I mentioned above.

Sort the strategies by popularity and backtest each one.

This is a decent method if you don't know where to start.

But you'll quickly learn that most of the free strategies don't work.

Yeah, you generally get what you pay for.

And there are so many strategies out there that it would take forever to test them all.

So once you get tired of looking for random ass strategies, it's time to get smarter.

A better way to approach this proess is to start by asking yourself what type of strategy you're looking for:

  • Do you prefer trend strategies?
  • Do you want to trade a RSI strategy?
  • Do you want to day trade?

Then take a look at all of the strategies that fall into your chosen category.

Search keywords related to the type of strategy you want to find. 

Backtest them and see how they perform.

Again, chances are very good that they won't work.

But they might.

Worst case scenario, they will give you a good starting point and ideas for your own strategy.

This is a huge benefit of the TradingView Community.

How to Create Your Own Strategy

Since many of the trading strategies on TradingView are free and open source, you can use them to help build your own strategy quickly.

First find a free strategy that you want to build on.

Then create your own Pine Script project by clicking on the Pine Editor tab at the bottom of the screen.

TradingView Pine Editor

Copy and paste an existing strategy into the Pine Script tab and start making adjustments.

Save the strategy, then run a backtest.

Yes, you need to learn Pine Script.

But most programming tutorials can be very boring.

When you know what you want and you have a starting template to get there, learning becomes much more fun and you'll usually see results faster.

Focus on the parts of the current script that you want to change and go from there.

To sign up for TradingView, go here.

Considerations of Historical Data Availability

When using the backtesting function in TradingView, it is important to understand how much historical data is being tested in each test.

Data availability will vary by market and timeframe.

Higher timeframe charts like the daily, weekly and monthly charts will usually have enough data to do valid tests.

But on lower timeframes, such as the 4-hour chart and below, the historical data is very limited.

You may only have access to two or three years of data, which is never sufficient to do a thorough backtest.

Be sure to read more about how to how many trades you need to have confidence in a trading strategy.

If you require the entire data set for a particular market, you'll need to subscribe to the Deep Backtesting feature, which is only available on the higher tier paid plans.

This is a big downside of the platform.

If you don't want to pay the higher TradingView monthly fee, there are other solutions such as Naked Markets, which usually provides much more historical data than TradingView and free ongoing data updates, for just a one-time investment.

Limitations and Downsides

Here are the limitations of TradingView to be aware of:

  • The backtesting function is only available on TradingView paid plans.
  • TradingView lacks sufficient historical trading data on the lower tier plans. It can be enough data on the higher timeframes, such as the daily chart. As you move down to lower time frames like the 4-hour or 1-hour chart, you may only get two or three years of data, which is not enough. You have to pay more for Deep Backtesting to get more comprehensive data.
  • There's no way to upload your own historical data.
  • You can only backtest one market, strategy and timeframe at a time. There is currently no way to backtest multiple variables simultaneously.
  • No offline testing.
  • The reporting metrics are decent, but still limited. I would like to see more detailed backtesting statistics.
  • Although TradingView's backtesting function is useful, it is not a substitute for live trading. You should still exercise caution and not rely solely on backtesting results. Be sure to implement Forward Testing before risking real money on a strategy.

While TradingView's backtesting function has its limitations and costs, it can be a valuable tool for testing trading strategies quickly.

Conclusion

Based on my experience with the backtesting function in TradingView, it's not for everyone.

It only really makes sense if you can do 2 things:

  1. Code in Pine Script
  2. Subscribe to a paid plan that has Deep Backtesting capability

One big benefit of the backtesting feature is that you can test community-created trading strategies and scripts.

Unfortunately, most of them are useless. That's no different than any other platform.

But they can be an excellent starting point to give you ideas for your own strategy.

If you want to backtest manually, TradingView also has a Bar Replay function that will eliminate the need to learn Pine Script.

So at the end of the day, backtesting in TradingView can make sense for some traders, but it's not for everyone.

That said, I strongly feel that TradingView is the best charting platform available and I highly recommend it for that.

 

The post The Ultimate Guide to TradingView Backtesting appeared first on Trading Heroes.

]]>
What is a Good Backtesting Result? https://www.tradingheroes.com/good-backtesting-result/ Thu, 20 Jun 2024 09:04:53 +0000 https://www.tradingheroes.com/?p=1025749 It can be tough to understand what a good result is when backtesting trading strategies. Learn what really matters here.

The post What is a Good Backtesting Result? appeared first on Trading Heroes.

]]>

When you buy something through one of the links on our site, we may earn an affiliate commission.

“Well duh, a good backtesting results is when you make 1,000,000% return.”

That's what many new traders think and that's why over 90% of traders fail.

If you want to become a successful trader, you're going to have to learn how properly evaluate a trading strategy and adjust your perception of what is a good backtesting result. 

Spoiler alert: Most successful trading strategies start off as mediocre or even poor. 

But through continual testing and iteration, they are made into profitable strategies.

Just like successful traders are made, not born…successful strategies require an investment of time and effort.

Where to Start

The first thing to understand about backtesting is that almost all successful trading strategies didn't start out that way. 

A great trading strategy is just like any great invention.

It starts with an idea and the inventor wants to solve a problem.

Traders want to solve the problem of making money consistently in the markets.

You will probably have to refine your trading strategy idea to make it profitable.

Once you understand that trading strategies rarely start off as profitable, it then makes sense that breakeven backtesting or slightly profitable results can actually be a good thing. 

If a strategy is breakeven (or close to it), then you just might have to do a few tweaks to get it to profitable.

Many times, experimenting with money management or exits can make a strategy profitable.

With that in mind, here are more details on what to look for in your testing results.

Historical Data Used in Backtests

Before I get into analyzing your actual backtesting results, one important thing to consider is how much historical data was used in your backtests.

Many backtesting platforms only give you 1 or 2 years of backtesting data.

This is not nearly enough to figure out how a strategy will perform over different market conditions and cycles.

So when you're backtesting, get as much historical data as possible.

Define a Review Period

Once you have a lot of historical data to test with, be sure to define your review period for your strategies.

If you are creating a strategy on the daily chart, you might want to review the returns on a yearly basis.

Now if you're testing on the 1 hour chart, you should probably review your monthly results.

Then figure out your average return per your review time period.

You probably won't be profitable in every review period, but you want to see what type of drawdowns you'll have to endure and what to expect from the trading strategy.

This analysis will allow you to compare trading strategies in an objective manner and judge which strategies you may want to pursue and which ones to drop.

Set a Goal

Now it's time to figure out what matters to you.

A “good” trading strategy has to be good for you and nobody else.

It won't necessarily be the most profitable or the most consistent.

But if it meets your income needs, then that's all that matters.

A word of caution here…

Many traders (myself included) start out with unrealistic goals for their strategies.

So set a goal, but you might find yourself having to adjust what you expect out of one trading strategy.

You might have to trade several trading strategies or markets to get the results you're looking for.

Don't get discouraged however, if you keep working the results will come.

How to Identify Trading Strategies with Potential

There are 3 basic types of backtesting results:

  1. Terrible
  2. Breakeven
  3. Profitable

Now I'll define each and show you what to look for in each.

A Terrible Backtesting Result

audusd m5 results

This one is obvious.

If the strategy loses 80% of the account or more, then you probably shouldn't spend any more time with it.

The strategy above lost 99.82% from 2009 to 2024.

That's as bad as it gets.

Trying to optimize a strategy with a terrible result is like polishing the brass on the Titanic.

It's best to move on and use your time and brain power to create a new strategy.

A Breakeven Backtesting Result

EURUSD 4-hour results

Here's where things get exciting. 

Most new traders will throw away a breakeven strategy, but not you because you're reading this article.

A breakeven strategy can potentially be optimized and made much more profitable.

It might just need a tweak or two to work well.

Here are some questions to ask when trying to improve a strategy:

  • Can you eliminate the biggest losers easily?
  • Do losing trades have a common characteristic? Maybe they go longer than 2 days or they are taken during a certain time of day.
  • What happens if you set a bigger profit target?
  • Can you increase your stop loss, while risking the same percentage of your account, so you don't get stopped out so often?
  • Will using a trailing stop loss improve your results?
  • How do your results change of you increase or decrease your risk per trade? It may be counterintuitive, but lowering your risk per trade can sometimes increase your total return.

Those are the major things to consider when trying to improve the performance of a strategy.

But don't stop there, what else can you think of?

A Profitable Backtesting Result

Backtesting results graph

Now we get to the result that everyone is looking for, a profitable result on the first try.

It doesn't happen often, but it is possible.

I've only had a hugely profitable result on the first try…twice.

But even if your results were profitable, you can't stop there. 

You need to double check your results.

Real world trading could vary dramatically from backtesting results if you don't account for everything.

Consider the following:

  • Did you properly account for commissions, spread, slippage and fees?
  • Will you be awake to take trades when they setup?
  • Did you follow the trading plan?
  • Did you run a Monte Carlo simulation to see your maximum potential drawdown?

Once you've verified that your results are good in a program like NakedMarkets, Forex Tester or FX Replay, congratulations, you now have a profitable trading strategy.

Now it's time to move on to Forward Testing to be sure it works.

This is a key step to making absolutely sure that your strategy works before risking your full trading capital.

But don't stop there.

Continue to test ways to potentially make your strategy better.

See if you can increase the return or decrease the drawdowns.

Pick the one that's more important to you.

Consider trading 2 or 3 versions of your strategy at the same time to diversify your risk.

Once you're trading your strategy with your full-sized account, then you can repeat the process to find another profitable strategy.

Final Thoughts

Again, you probably won't get a super profitable backtesting result on your first try.

The key is to be able to spot the diamonds in the rough.

From there, you can work on developing each strategy to its maximum potential.

It's also important to be able to figure out which strategies will never work and stop trying to improve them right away.

Remember that trading strategies usually tend to perform a little worse in real life.

So account for that and don't get too excited about a huge return.

Before I go, I'll leave you with a conversation that we had about this topic on the Think Profit Podcast.

It will give you more ideas on what to look for when you're backtesting.

The post What is a Good Backtesting Result? appeared first on Trading Heroes.

]]>
How to Manually Backtest Multiple Markets at the Same Time https://www.tradingheroes.com/backtest-multiple-symbols/ Thu, 13 Jun 2024 01:10:32 +0000 https://www.tradingheroes.com/?p=1025551 Learn how to backtest multiple markets at the same time and save time. This can be done on multiple backtesting platforms.

The post How to Manually Backtest Multiple Markets at the Same Time appeared first on Trading Heroes.

]]>

Backtesting multiple markets at the same time has several benefits.

The short version is that you'll save time and you can test based on market correlations.

This process will be similar to backtesting multiple timeframes at the same time, but will require a couple of additional setups.

Backtesting multiple markets is easy with an automated strategy.

Just run the trading program against data from different markets.

But viewing multiple markets at the same time is not as easy with manual testing.

In this quick tutorial I'll give you the benefits and downsides of manual multiple market backtesting and exactly how to do it.

Benefits of Backtesting Multiple Markets Simultaneously

If you already know about the benefits of backtesting multiple markets, skip down to the section on setups.

But if you aren't sure why you should do it, here are the top 2 reasons.

Save Time

Trader at yacht harbor

First, testing multiple markets can save you a ton of time.

Let's say that you want to manually backtest a trading strategy on the EURUSD and the S&P500 at the same time.

Furthermore, let's say that testing each market individually will take you 2 days.

If you run both charts at the same time and take trades on both charts, it might only take 2.5 days to do your test instead of 4 days.

This is a huge benefit.

See Market Correlations

The other reason to backtest multiple markets at the same time is to see market correlations.

For example, a frequently talked about correlation is between the CADJPY and Oil.

Since Canada is a major oil exporter and Japan imports all of its oil, the price of oil can effect each economy accordingly.

As always, don't take my word for it, backtest it yourself.

There are many other market dynamics at play with regard to currency prices, so the price of oil isn't always going to be the biggest influence.

But if you want to test this, it can be tough to see the correlation (or lack thereof) if you are only backtesting one market at a time.

Having both charts side by side makes this easy.

Downsides of Backtesting Multiple Markets Simultaneously

Multiple market backtesting is not all sunshine and unicorns though.

Here's what you should be aware of if you're going to do this.

Loss of Focus

One potential downside is that you could miss some signals, if you have too many markets open at the same time.

So if you want to test on multiple markets, you have to be super focused.

It's really easy to miss trades when you have several charts going at the same time.

I would suggest not testing more than 3 markets at the same time…max.

Two markets is ideal.

Computer Slow Down

If you have too many markets open at the same time, this can also slow down your computer.

Your trading program will have to update the data for each chart and also calculate your indicators (if you're using any).

Depending on how powerful your computer is, and which backtesting software you're using, this might slow things down.

So be sure that you have a decent computer and software that can handle this.

The most important spec on a computer is going to be the amount of RAM you have.

Processor speed does contribute to the overall speed, but as long as you have a processor made in the last 5 years, you'll see way more gains from RAM.

At least 16GB is recommended, but 32 GB or more is ideal.

How to Setup a Backtest in Multiple Markets

Alright, now that you have some background on multi-market manual backtesting let's get into actually how to do this.

I've personally done this with NakedMarkets and Forex Tester, but this will work in a similar way in other programs.

It's not possible to do this in something like MetaTrader.

If your software cannot do this, I would highly suggest switching to NakedMarkets.

This software is much more optimized for multiple market backtesting than Forex Tester.

I'll use NakedMarkets for the rest of this tutorial because that's what I use.

Step 1: Download Historical Data

You're going to need some data to test with, so the first step is to go to: Tools > Data Center and download historical data for the markets you want to test.

NakedMarkets provides updated historical data for free, no subscription needed.

NakedMarkets Data Center

Step 3: Setup the Backtest

Once the data is loaded, it's time to add your charts and set them up.

Go to: File > New Backtest

New backtest

Name your backtest and the starting balance for the account.

Then click Next.

Create new backtest

The choose the markets you want to backtest. Be sure to select more than one market on this screen.

Click on Next.

markets to backtest list

Use the default settings on the last screen and click on Finish.

Last screen

Now a window for each market will open.

Charts open

Resize the windows to your liking.

Resize charts

If you need to add more windows, click on: File > Add New Chart and select the chart you want to add.

You'll only be able to add markets that you selected when you created the backtest.

Keep in mind that you can also have multiple timeframes for each market.

Simply add another chart for each market, then change the timeframe of the second chart.

You can also change the timeframe of each chart by clicking on the chart you want to change, then clicking on the timeframe buttons in the upper left corner of the screen.

Once all of your charts are setup, it's time to start backtesting!

Step 4: Press Play and Start Taking Trades

The hard part is done, now it's time to start testing.

Press the play button in your software and it will advance all of your charts at the same speed.

Play button in NakedMarkets

Take trades according to your trading plan.

Step 5: Review Your Results

Once you've completed a full round of backtesting, it's time to see how well you did.

A common mistake is to judge a trading strategy purely on its total return.

Professionals examine at all aspects of a strategy to identify its potential because most strategies won't have good results on the first try. 

There are 3 main questions that you should ask yourself when reviewing your backtesting results:

  • Can I possibly improve this strategy? This is usually possible when a strategy is near breakeven. Consider experimenting with your risk management or exits.
  • Can I potentially trade this on different timeframes or in multiple markets at the same time? This can give you more trades, if lack of trades is your problem.
  • Is the overall trend of account balance good? If your strategy wins consistently, but has a low overall return, then you might simply need to increase your risk.

Read more about how to optimize your strategies in this article.

Be willing to experiment with your strategy until you find something that works.

That's the beauty of backtesting.

You'll get a good idea of what works BEFORE you actually risk real money.

There is also a creative element, which makes it fun to try out new ideas that you come up with.

Conclusion

So that's why and how to manually backtest your trading strategies in multiple markets at the same time.

If you've been testing one market at a time, this can be a game changer.

It will allow you to find profitable trading strategies and eliminate losers faster.

Happy testing!

 

The post How to Manually Backtest Multiple Markets at the Same Time appeared first on Trading Heroes.

]]>
How to Create a No-Code, Automated 50-200 MA Crossover Strategy https://www.tradingheroes.com/no-code-automated-50-200-ma-crossover/ Thu, 30 May 2024 21:25:35 +0000 https://www.tradingheroes.com/?p=1025485 Learn how to build a fully automated 50-200 moving average crossover trading strategy, backtest and optimize a strategy.

The post How to Create a No-Code, Automated 50-200 MA Crossover Strategy appeared first on Trading Heroes.

]]>

The 50-200 Moving Average Crossover is an easy concept to build a trading strategy around because the inputs are simple and the potential optimizations are straightforward.

So it's perfect if you're just getting started with trading strategy development.

Many trading websites will give you what they say is the “best” 50-200 crossover strategy.

Interestingly, most of them don't give you any data to back up that claim.

I'm going to give you information that's much more useful.

In this tutorial, I'm going to show you how to backtest any Moving Average Crossover trading strategy on the internet to find out for yourself, if it really works or not.

Using this method will also allow you to test your own optimizations to see if you can improve on the strategy.

The best part is that you can use this method to backtest strategies very quickly because the backtests will be 100% automated.

You don't need to know how to write code to do this, it's all drag and drop.

I'll also show you some of my own backtesting results so you know good places to start with building your own strategy, and what to avoid.

Alright, let's get into it…

What is the 50-200 Moving Average Crossover Strategy?

This trading strategy is also known as a Golden Cross and Death Cross.

That's way too much drama for me, so I'm just going to call it the 50-200 Moving Average Crossover trading strategy.

As the name suggests, this strategy uses the 50 and 200 Simple Moving Averages (SMA).

Here's what that looks like on a chart.

Moving Average crossover on chart

The 50 SMA is considered the “fast” SMA because it reacts faster to price changes.

So naturally, the 200 SMA is the “slow” moving average because it takes awhile to react to price.

Basically, traders who use this method buy when the 50 crosses above the 200 and sell when the 50 crosses below the 200.

Sounds pretty easy right?

Well, not quite.

There are a few more things that have to be defined to make this a complete trading plan.

First, I'll create the trading plan, then I'll show you how to do an automated backtest of the plan, without writing a single line of code.

The 50-200 Crossover Strategy Trading Plan

Here are the rules for this plan:

  • Buy
    • Buy on the close of the candle when the 50 SMA crosses above the 200 SMA
    • Stop Loss at last swing low
    • Risk 1% per trade
    • Take profit at 1R (1 times risk)
  • Sell
    • Sell on the close of the candle when the 50 SMA crosses below the 200 SMA
    • Stop Loss at last swing high
    • Risk 1% per trade
    • Take profit at 1R (1 times risk)

Remember that this is just a starting point.

Any of these settings can be changed and retested. 

So do a couple of tests with these settings, then feel free to experiment with your own settings.

Get creative.

You never know, you might just develop a super profitable moving average crossover trading strategy.

How to Build the Automated Strategy

Now let's get to work.

For this backtest, I'm going to use NakedMarkets.

It's the easiest way to build automated trading strategies with no-code.

Once you complete these initial setups, you'll be able to test all of your 50-200 moving average crossover trading strategy ideas easily.

Create the Core Rules

The first step is to create the Core Rules.

This is what will tell NakedMarkets how to identify the initial setup conditions for a trade.

You have to create one Rule for long trades and one for short trades.

This will also be true for most of the other types of Rules.

Here's how to setup your first Core Rule:

  1. Open NakedMarkets and go to: Rules > Rule Manager
  2. Click the New Rule button in the lower left corner of the window
  3. Name the Rule in this format: [strategy name] Core [long or short]
  4. Select Core as the Rule type
  5. Click OK

Now it's time to add conditions to your new Rule.

Long Trade 

Let's setup a long trade.

To add a criteria, click the (+) symbol in the upper right corner of the screen.

From there, drag the conditions you want to use from the list on the right.

Add condition to NakedMarkets

These are the settings for each of the boxes, from left to right:

  1. Moving average: Period (50), MA Type (SMA)
  2. Greater than
  3. Moving average: Period (200), MA Type (SMA)
  4. And
  5. Moving average: Period (50), MA Type (SMA), Previous Bar (1)
  6. Less than
  7. Moving average: Period (200), MA Type (SMA), Previous Bar (1)

The reason that I'm putting 2 moving average comparisons in there is because I want to evaluate the position of the 50 SMA relative to the 200 SMA for the current candle and the previous candle.

I want to see the previous candle have the 50 below the 200 and the current candle have the 50 above the 200.

This will give me every situation where the 50 has just crossed above the 200.

If I don't do this, I will get a signal every time the 50 closes above the 200 and that would not work.

This is what your screen should look like after you're done.

Long Core Rule

Click on the Save Rule button in the lower left corner to save your Rule.

Now I'm going to do the same thing for the short side.

Short Trade 

Here's how to setup the Core Rule for a short trade.

The easiest way to create a new Rule is to clone the long trade and just change the settings that apply to a short trade.

To clone a Rule, right-click on the long Rule in the list on the right side of the screen and select Clone Rule.

Clone NakedMarkets Rules

Then right-click the cloned Rule and rename it.

Change “long” to “short” in the name.

So in this example, the new name of your short trade will be: “MA Cross Core Short”.

Now it's time to change the settings of this Rule to look for short trades.

This is what the short Rule looks like:

Short Core Rule

Here are the settings for each of the boxes, from left to right:

  1. Moving average: Period (50), MA Type (SMA)
  2. Less than
  3. Moving average: Period (200), MA Type (SMA)
  4. And
  5. Moving average: Period (50), MA Type (SMA), Previous Bar (1)
  6. Greater than
  7. Moving average: Period (200), MA Type (SMA), Previous Bar (1)

Click on Save Rule in the lower left corner to save your Rule.

Great work, you just completed the hardest part of this tutorial!

There are 2 more steps that you have to complete before you can start testing this strategy, so let's keep going.

Create the Entry Rules

Now that you have the Core Rules that will identify the basic criteria of the entry, it's time to create the Entry Rule that will determine the details of each entry, such as the entry type, stop loss, risk per trade and stop loss.

To do this, go back into the Rule Manager and click the New Rule button in the lower left corner of the screen.

Again, we will start with the long Rule, then clone it to make the short Rule.

Long Rule

Name your long Rule: “MA Cross Entry Long”.

Here's what your long Entry Rule will look like:

Entry trade long

For the order type and lot size, double click on the box to change the settings.

With the other boxes, drag the appropriate Default Rule from the upper box on the right side into the stop loss and take profit boxes.

Here's how to set that up:

  • Instant Order: Buy
  • Stop Loss: Last swing low
  • Take Profit: 1R
  • Lot Size: 1%

Click on the Save Rule button in the lower left corner to save your Rule.

Short Rule 

MA cross short entry

Now clone the long Rule and use these settings to create the short Rule:

  • Instant Order: Sell
  • Stop Loss: Last swing high
  • Take Profit: 1R
  • Lot Size: 1%

Click on the Save Rule button in the lower left corner to save your short Rule.

Create the Setup Rules

Alright, these are the final Rules!

Don't worry, this step is super easy.

A Setup Rule basically ties everything together and monitors your chart to see if the Core Rule criteria is present.

If it is, then it executes the Entry Rule.

Long Trade 

Go back into the Rule Manager and click the New Rule button in the lower left corner of the screen.

Create a new Setup Rule, then name it: “MA Crossover Setup Long”.

Setup Rule long

First, drag the Core Rule you created from the User Rules section into the top Setup Condition box.

Under Actions, drag the Entry Rule you created into the Actions box.

Now clone this long Rule and rename it to create the short Rule.

Short Trade

Setup Rule short

Replace the Setup Condition and Action with the short trade versions of your Rules.

That's it for Setup Rules!

Run the Backtest in Visual Mode

That was pretty easy right?

Now here's the fun part, you're going to actually backtest this strategy.

You should do this step first, before using Fast Backtest because it will allow you to see any errors that you made when creating your Rules. 

Close the Rule Manager and go back to the main NakedMarkets screen.

Start a backtest by going to File > New Backtest.

New backtest

Name your backtest, then select your starting balance.

Click on Next.

Backtest 1

Select the market(s) you want to include in the test, then click on Next.

On the next screen, you can select the timezone you want to use.

I usually use the default settings, so if you aren't sure about your timezone, just use the default settings.

Click on Next.

Select timezone

Now click and drag both the long and short Setup Rules that you created onto the chart.

You'll see these Rules that you're currently using in the upper left corner of the screen.

Add setup to chart

Select the right timeframe that you want to backtest on.

The timeframe shown above is the daily chart.

Then click on the Play button in the toolbar to start the backtest.

Play button in NakedMarkets

If you setup your Rules correctly, you'll see the trades automatically execute on your chart.

Watch the trades carefully to be sure that they are executing correctly.

Now if your trades are not executing correctly, see the section below on troubleshooting.

However, if they are working, then congratulations, you have just build your own automated 50-200 Moving Average Crossover trading strategy!

Once the backtest is completed, you can see the detailed stats by doing the following:

  • Save the backtest by going to: File > Save Backtest
  • Go to: Statistics > Statistics Center
  • In Stat Center, go to: Source > Import from backtest
  • Select the backtesting file you just saved

This will show you the stats on your backtest.

A word of caution here…

You probably won't have a super profitable strategy on the first try.

However, remember that this is a process and your results could be significantly better if you use different settings or run it on a different timeframe or market. 

You might get better results on the EURUSD 4-hour chart, or the SP&500 1-hour chart.

The return might be better if you use a different stop loss or change the moving average settings.

Again, don't get discouraged if your first test doesn't work out.

Remember that this will require some work and very rarely will even professional traders gets an awesome result on the first try. 

Therefore, be willing to experiment and treat this process like an inventor would.

Many times, inventors have to try many different prototypes before they get something that works well.

It's been said that Edison tried 10,000 ideas before he invented the light bulb.

Hopefully you won't have to try that many strategies before you find a good one, but you have to be willing to potentially stick it out for that long.

Regardless of the return on your first test, once your strategy is working in Visual Mode, now it's time to shift your backtesting into high gear.

Hit “Turbo Boost” and Run a Fast Backtest

Now that you're confident that everything is working correctly with your moving average crossover strategy, it's time to take your backtesting to the next level.

In this step, you're going to unleash “turbo mode” and use the Fast Backtest feature in NakedMarkets.

This will allow you to backtest multiple markets and timeframes, without having to setup each backtest individually.

To do this, go to: Tools > Fast Backtest

Then select the market(s) you want to backtest.

You can test as many as you want.

Click on Next.

Fast backtest step 1

Next, choose the timeframe(s) you want to backtest.

Again, you can select multiple timeframes.

Click on Next.

Fast backtest 2

Now select the Setup Rules that you want to backtest.

Select the moving average crossover Rules that you created above, under Setup Rules.

Click on Next.

Fast backtest step 3

Then you'll see the list of Fast Backtests that will be run.

Click on Launch to start the backtest(s).

Fast backtest 4

Once a backtest is finished, you'll see the basic statistics in this window.

There is also a link to the detailed stats in the [Load stat] link.

Load stats link

Click on the link to open Statistics Center and you'll see the complete results of each backtest.

MA cross results

As you can see, this test on the daily chart didn't work well.

But at the same time, it wasn't completely terrible either.

At least it was profitable for a period of time.

Losing 4.25% from 2006 to 2024 is also essentially breakeven.

So this strategy could be improved by using different settings in the strategy.

Again, this is a process and don't get discouraged by poor results on your first tries. 

Troubleshooting Your Rules

Even with a simple trading strategy like this, it's possible to make mistakes in the Rule creation process.

This is especially true when cloning Rules.

I actually made couple of mistakes when creating this tutorial.

So if your strategy isn't working as you expected, don't worry.

Just go back through the steps above and double check your Rules.

The most common mistakes are:

  • Not changing the greater-than or less-than criteria.
  • Having the wrong trade direction (buy or sell)
  • Using the wrong settings for an indicator

If you cannot see the error by just looking at the Rules, then there are 2 more things you can to do troubleshoot your strategy.

First, in your Setup Rules, change the Action to Pause Backtest, instead of using the Entry Rule as the Action.

This will take the Entry Rule out of the equation and allow you to only focus on the Core Rule.

Right-click on your chart and select: Detach all Rules.

Then drag your new Setup Rules onto your chart and run the backtest again in Visual Mode.

Every time the trade sets up, the chart will stop.

This will allow you to double check the logic of the Rule.

If your Core Rule is working correctly, then the mistake should be in your Entry Rule.

To test this, simply use the Entry Rule by itself by dragging the Rule from the list on the left of the screen onto the chart.

Add Entry Rule to chart

You can do this at any time, you don't necessarily have to wait for your entry criteria to be met.

This will open a trade and allow you to see if your Entry Rule is working as expected.

These methods will allow you to debug your trading strategy.

Stay calm and go through your Rules step-by-step.

If you cannot find the problem, head over to the NakedMarkets Forum and ask for help.

Potential Improvements

If you didn't get the results you were looking for in your backtests, here are a few ideas on how you can potentially improve your results:

  • Change the period of the moving averages
  • Use different types of moving averages, like an exponential moving average
  • Test different timeframes
  • Adjust the settings on the last swing high/low indicator
  • Test different markets
  • Use a different stop loss level
  • Use a different take profit level
  • Trail your stop loss
  • Risk more per trade
  • Risk less per trade
  • Add another indicator to create a second entry criteria
  • Use a strategy across multiple timeframes or markets at the same time to potentially increase profits and diversify risk

But don't stop there, what else can YOU think of?

Backtesting Results

All of this is great in theory, but how well does this strategy actually work?

That's what you're going to find out in the following links.

I'm going to backtest different ideas around this trading strategy, starting with the method described above.

The version above will be version 1 and I'll create a new version every time I make a change to the original strategy.

Rules for new versions will be available via the links below.

As I do new backtests I'll add them to the appropriate pages.

You'll see all of the stats for each backtest.

Even if a backtest doesn't do incredibly well, it can give you a starting point for creating a strategy of your own.

These tests also show you what to avoid and will save you time in the testing process.

Here are the versions that I've currently tested:

Conclusion

So that's an easy way to do a fully automated backtest of the 50-200 Moving Average Crossover strategy.

This is a great method to build a trading strategy around because it's so simple and provides many opportunties for optimization.

But remember that you must backtest every trading strategy yourself.

You cannot rely on my results or the results of anyone else.

To develop real confidence in a strategy, you must see hundreds or even thousands of trades, and test many different ideas.

Luckily, NakedMarkets speeds up this process dramatically.

I've given you the template…now get to work.

You can get a discount and some fantastic bonuses for NakedMarkets here.

If I missed something in this tutorial, let me know here.

 

The post How to Create a No-Code, Automated 50-200 MA Crossover Strategy appeared first on Trading Heroes.

]]>
50-200 Moving Average Crossover Strategy v1 Backtesting Results https://www.tradingheroes.com/50-200-ma-cross-strategy-v1-results/ Thu, 30 May 2024 21:24:57 +0000 https://www.tradingheroes.com/?p=1025547 See backtesting real results for the first version of the 50-200 Moving Average Crossover trading strategy. Detailed stats included.

The post 50-200 Moving Average Crossover Strategy v1 Backtesting Results appeared first on Trading Heroes.

]]>

In a previous article, I showed you how to create a fully automated 50-200 moving average crossover trading strategy, without coding.

Now I'm going to show you the backtesting results of that strategy for every market that I've tested.

I'll show you both the good and bad.

You have to backtest this strategy yourself to make sure that you're comfortable with it and that it actually works with your broker.

Even if a strategy doesn't work well, you can test ideas on how to improve it and make it much more profitable.

Now let's move on to the trading plan and the results for each market.

Remember: This is only a starting point for YOUR trading strategies. This is for informational purposes only and the results below will not guarantee successful trading. 

As I backtest new markets, I'll add the results to this page.

Bookmark this page and check back periodically if you want to get future updates.

The 50-200 Crossover Strategy Trading Plan

Moving Average crossover on chart

Here are the rules for this plan:

  • Buy
    • Buy when the 50 SMA crosses above the 200 SMA
    • Stop Loss at last swing low
    • Risk 1% per trade
    • Take profit a 1R (1 times risk)
  • Sell
    • Buy when the 50 SMA crosses below the 200 SMA
    • Stop Loss at last swing high
    • Risk 1% per trade
    • Take profit a 1R (1 times risk)

Be sure to read the full 50-200 Moving Average Crossover automated strategy tutorial to learn how I did these backtests in just a few minutes, without coding.

Backtests

EURUSD

Weekly Chart

On this timeframe, there isn't enough data to pursue this strategy.

With only 10 trades, you simply won't get enough trades to make this viable.

EURUSD W 50-200 Crossover

Daily Chart

This actually looks pretty good.

True…the return is very low, but the max drawdown is also low and the strategy stayed profitable throughout the entire test.

So this could be a good strategy to optimize, or trade in multiple markets, assuming that the results are favorable in those markets too.

No guarantees obviously, further testing would have to be done.

EURUSD D chart 50-200

4-Hour Chart

This strategy was profitable for most of the testing period, so this could be a good timeframe to start experimenting with.

Yes, the return was breakeven.

But the graph is more promising than most of the others on this list.

It executed 209 trades, which is decent.

If this works in other markets, then the combined return could produce a significant return.

Again, backtest this for yourself.

This is only meant to be a starting point.

EURUSD 4-hour results

1-Hour Chart

The return on this strategy was breakeven, so there is potential to possibly optimize this timeframe.

On the upside, the strategy did execute quite a few trades.

EURUSD 1-hour 50-200 moving average crossover results

30-Minute Chart

The results on this timeframe are not worth examining further, at least with this version of the strategy.

EURUSD 30m

5-Minute Chart

The results are terrible on the 5-minute chart, so no further analysis is necessary.

EURUSD 5min backtesting results

AUDUSD

Weekly Chart

Not enough trades here to start using this timeframe.

AUDUSD weekly results

Daily Chart

This could be tweaked because the results are breakeven. The biggest issue is that there aren't very many trades, so I wouldn't pursue this one.

AUDUSD daily results 50-200

4-Hour Chart

Another breakeven result, so it might be something worth tweaking.

AUDUSD H4 50-200 crossover chart

1-Hour Chart

Breakeven again. Maybe it's worth a few tweaks, but I wouldn't spend a lot of time on it.

AUDUSD H1 results

30-Minute Chart

Pretty terrible results, so probably not worth messing with. Move on.

AUDUSD M30 chart backtesting results

5-Minute Chart

Just like with the EURUSD, the 5-minute chart is completely useless, so this is not worth exploring.

It pretty much blew out the account.

audusd m5 results

Notes and Observations About this Strategy

So far, the lower timeframes are showing much worse results.

Therefore, it might be better to stick to the daily and 4-hour charts.

Also, the stop loss on this strategy may not be ideal.

Sometimes the stop ends up being too far away and it takes awhile for price to hit the target.

More testing and optimization would have to be done.

Learn how to build and tweak this strategy and test your own ideas and you might come out with better results than me.

Conclusion

So that's how this strategy stacks up in all of those markets.

I'll be adding new backtests as I do them, so be sure to bookmark this page and check back periodically to see if I have any new markets.

Remember that you should always backtest a strategy for yourself. 

Never rely on the results of others, including me. 

To learn exactly how I created an automated program to do the backtests above, WITHOUT coding, read this tutorial.

 

The post 50-200 Moving Average Crossover Strategy v1 Backtesting Results appeared first on Trading Heroes.

]]>
How to Manually Backtest Multiple Timeframes at the Same Time https://www.tradingheroes.com/manually-backtest-multiple-timeframes/ Thu, 25 Apr 2024 10:38:42 +0000 https://www.tradingheroes.com/?p=1025550 Learn how to have different timeframe charts open at the same time while you're backtesting. This is easy and will speed up the process.

The post How to Manually Backtest Multiple Timeframes at the Same Time appeared first on Trading Heroes.

]]>

In this tutorial, I'll show you how I backtest multiple timeframes at the same time.

You'll learn how to setup multiple charts and have them all run at the same speed while you backtest.

This is easy to do.

There are many software solutions that can do it, but it may not be obvious how to do it, if you don't know what to look for.

Here's what it looks like on my laptop.

Multiple timeframe backtesting

As you can see, I have the Daily, 4-hour, 1-hour and Weekly charts open.

Having multiple charts running at the same time has many advantages, which you'll learn about in this tutorial.

If you want to learn more about backtesting in general, be sure to read my backtesting guide on how to backtest in any market.

Alright, let's get into it…

Why Backtest Multiple Timeframes at the Same Time?

There are many reasons that you may want to have multiple timeframes open at the same time.

I feel that most traders will benefit from watching more than one timeframe when backtesting.

First, when you have multiple charts open at the same time, you don't have to flip back and forth between the different timeframes to check things like pivot points, trendlines or support/resistance levels on higher timeframes.

This alone can save you a ton of time.

Another reason to use multiple timeframes is that you can take trades on all of those timeframes.

Let's say that you want to backtest the same trading strategy on the Daily, 4-hour and 1-hour charts.

Having the ability to take trades on all of those charts at once will be much faster compared to testing each timeframe individually.

Now, I've personally found this a little hard to do in the past.

But if you have Rules setup on each of your charts, then you can have your backtest pause every time a trading setup condition happens.

Finally, you can not only test multiple timeframes at the same time, but you can also have charts of multiple markets running at the same time.

I'll get into multiple markets in another tutorial, but for now, let's take a look at how to setup the charts.

How to Setup a Backtest With Multiple Timeframe Charts

I'll demonstrate how to do this with NakedMarkets because that's what I use.

But the process will be similar, regardless of which software you use.

This method also works in Forex Tester and other software.

First, open NakedMarkets and start a new backtest.

New Backtest

Select the settings for your backtest, along with the market you want to test.

Backtest setup

Once you've finished the setups, you'll see a blank chart.

Blank backtesting screen

Now go to: File > Add new chart > [your current market]

This will add another chart.

Multiple charts open

If you want to add more timeframes, keep adding charts until you have all of the charts you want.

Then resize each chart so they all fit nicely on your screen.

You can also layer the charts if you want the charts to be bigger.

Now select each chart and change the timeframe to the one you want to display on that chart by clicking on the timeframe selectors in the toolbar.

backtesting timeframes

You can see the timeframe of each chart in the upper left corner of the window.

Chart timeframe display

Once you have setup the timeframes for each chart, select the timeframe that want to advance all of the charts at.

You can do this by selecting the Step timeframe in the toolbar, next to the Play button.

Backtesting steps

For example, if you select the 5-minute timeframe, all charts will advance in increments of 5 minutes.

Now click the Play button and the charts will move forward in unison, based on the timeframe that's currently selected in the Step setting.

To take a trade, simply right-click on any chart and enter a trade.

trading menu

Since all of the charts are moving forward at the same speed, it doesn't matter which chart you take the trade on.

Your trades will appear on all charts at the same time.

It's usually best to select a low timeframe in the Step setting because that will show you the greatest level of detail across all the charts.

Doing this will also help you see what candles look like on the the higher timeframe charts, before they close.

Many times, traders don't wait until a candle closes before taking a trade.

This can lead to impulsive trading.

Watching a candle unfold will help you understand the emotions that you can potentially go through as the candles develop.

Alright one last thing…

You can add Rules to each chart to take trades or simply pause the chart every time your setup happens.

To do this, simply drag the Rule you want to use from the folders on the left, onto the chart you want to use it on.

Drag Rule onto chart

Conclusion

Now you know how to do a backtest on multiple timeframes at the same time.

Using this method will save you a lot of time and help you find profitable trading strategies faster.

This can be done on many different backtesting platforms, so find out if your software can do it.

If your software can't do it, then consider using NakedMarkets.

It's what I use.

All that's left is to finish your first backtest.

Go for it!

 

The post How to Manually Backtest Multiple Timeframes at the Same Time appeared first on Trading Heroes.

]]>
Monte Carlo Simulation in Backtesting: Why All Traders Need It https://www.tradingheroes.com/monte-carlo-simulation-backtesting/ Thu, 11 Apr 2024 20:45:53 +0000 https://www.tradingheroes.com/?p=1025462 Monte Carlo simulations are important in automated and discretionary backtesting. Learn what it is, how to do it and why it matters.

The post Monte Carlo Simulation in Backtesting: Why All Traders Need It appeared first on Trading Heroes.

]]>

When you're testing trading strategies to gauge their profit potential, backtesting is a crucial step.

But it's not enough to just stop at the total return of a strategy in backtesting.

There are many metrics that should be studied to assess the viability of a strategy, and if it will meet your goals.

A Monte Carlo simulation is a mathematical technique that can be used to stress test a trading strategy. It runs backtesting results through hundreds, or even thousands of possible scenarios, which helps traders uncover weaknesses and potential issues. 

I've found Monte Carlo simulations very useful and in this article, I'll show you how they work, how to do a simulation and how to use the data from a simulation to make trading decisions.

Fundamentals of Monte Carlo Simulations

When you buy something through one of the links on our site, we may earn an affiliate commission.

Trading computer

Here's a little historical background and key elements to how simulations work.

They will help you understand the value of them and how to use them in your backtesting process.

Historical Overview

There is a lot of debate over who created this method and how long ago it was developed.

Some historians believe that similar methods were used as far back as ancient Babylon.

When you think about it, this process is pretty common sense.

So it would make sense that it's been in use for a long time, not just in the modern era.

However, the name “Monte Carlo Simulation” looks like it was developed during the 1940s, named after the famous Monte Carlo Casino in Monaco due to its elements of chance and randomness.

Statistical Principles

At its core, Monte Carlo Simulation relies on the Law of Large Numbers.

You leverage this by generating a large volume of random samples to represent a statistical distribution.

The theory is that the results converge on the expected value as the number of simulations increases.

It assumes that:

  • Actual outcomes can generally be determined by the probability achieved through many simulations
  • Statistical properties (such as mean and variance) are known
  • The Probability Density Functions (PDFs) adequately represent underlying conditions

Algorithmic Components

Implementing a Monte Carlo Simulation involves the following steps:

  1. Define a domain: Identify the possible inputs that affect your model. When using a simulation with backtesting data, the domain will be the actual backtesting trades.
  2. Generate inputs randomly: Create random variables that mimic the behavior of real-world data. In backtesting, the random variable is usually the order in which the trades are executed. But other variables can be used like the overall win percentage and randomly skipping trades.
  3. Compute simulation: Run the simulation model using these inputs to produce a result.
  4. Aggregate results: Perform the simulation multiple times to create a distribution of possible outcomes. With the help of a computer program, you can run a simulation thousands of times to zero in on the most probably result.

By employing these components, Monte Carlo Simulation can provide insightful data on the risk and uncertainties of your financial models, which is critical for robust backtesting.

Application in Backtesting

Monte Carlo Simulation is a powerful tool for backtesting trading strategies, allowing you to understand the potential risks and rewards by simulating various market conditions.

Establishing Parameters

First, you need to define the variables that will affect your trading strategy.

These include the initial capital, position sizing, stop-loss levels, and profit targets.

By setting these parameters, Monte Carlo Simulation helps you test the strategy against a range of outcomes to gauge its effectiveness.

Modeling Market Scenarios

Next, you'll generate many hypothetical market scenarios using historical price data.

This step involves randomizing trade order and considering the volatility/correlation between different instruments.

You can then apply your trading strategy to these simulated scenarios to measure its performance under various hypothetical market conditions.

Risk Assessment and Management

Finally, the simulation provides a distribution of potential returns, helping you assess the risk associated with your strategy.

This is where you'll examine key metrics such as:

  • Maximum Drawdown: The largest peak-to-trough drop in your portfolio's value.
  • Value at Risk (VaR): The potential loss in value of a portfolio over a defined period for a given confidence interval.
  • Probability of Profit/Loss: The likelihood your strategy will result in a gain or a loss.

These insights enable you to refine your strategy, improve risk management practices, and adjust your expectations to align with the simulated realities of the strategy.

How to Do a Monte Carlo Simulation After Backtesting

As I mentioned earlier, software makes it easy to run simulations.

First, backtest your trading strategy.

This could be an automated or manual backtest.

Next, tell the simulation software to do X number of simulations, based on your actual backtesting trades.

I usually use 1,000 simulations, but you can use more or less, depending on your goals.

There are many software platforms that can do this, but I use NakedMarkets.

It strikes a good balance between ease-of-use and giving me useful information.

I simply tell the software the parameters of the tests and this is the report that it generates.

Click on the chart to see the screenshot in another tab.

Monte Carlo example

As you can see, I can randomize skipped positions, slippage and the order of my trades.

Skipping random trades is a good way to account for trades that you'll miss because you're away from the computer, on vacation, etc.

The fact that all of the simulations above show a very similar result is a good sign.

But that's just the tip of the iceberg when it comes to analysis.

Analyzing Simulation Results

After completing a Monte Carlo simulation, you are presented with a wealth of data.

It’s critical to analyze this information methodically to determine the effectiveness of your strategy.

Equity Curves

First, look at your equity curves.

Consistently upward trending curves indicate a potentially successful strategy.

As seen above, it's a good sign if the simulations are very similar.

If the results are very different, then that's probably a risky strategy because the outcome is less reliable.

Performance Metrics

To quantify your strategy's potential, focus on specific metrics:

  • Expected Return: Calculate the average of simulation outcomes to gauge the expected performance.
  • Maximum Drawdown: Look at the maximum drawdown across all simulations. This will give you an idea of your worst case scenario.
  • Average Win vs Average Loss: This is very important. Are your winners making up for your losers? This metric will tell you and also show you how much you can expect to profit.

By using these metrics, you can create a fact-based understanding of your strategy's strengths and weaknesses.

Best Practices and Limitations

Backtesting on laptop

Applying Monte Carlo simulation in backtesting offers valuable insights into financial models.

But it requires careful implementation and acknowledgment of its constraints to ensure effectiveness.

Ensuring Model Accuracy

To enhance the accuracy of your Monte Carlo simulation in backtesting, you need to input high-quality data.

Data quality is paramount as it directly influences the simulation's reliability.

Make sure to get clean data and get it from the source, whenever possible.

This means getting it directly from the exchange or broker.

A trusted third party data provider is also a good source for data.

Next, employ cross-validation techniques to test the robustness of your model.

This involves dividing your data into an optimization set and a validation set to prevent overfitting.

Backtesting on data that was not used in the optimization process will help you understand how well the strategy might handle unforeseen circumstances.

Common Pitfalls

One of the pitfalls in using Monte Carlo simulation is underestimating the role of market anomalies, which can skew results.

Be wary of overfitting, a model that performs exceptionally well on historical data may not necessarily predict future scenarios accurately due to its complex nature.

Also double check that your trading strategy has been implemented consistently.

If you changed your strategy in the middle of a test, your results will not be an accurate representation of your strategy and will be very likely to fail.

Finally, check that you're properly accounting for expenses like commissions, fees, spread, swap and slippage.

Advanced Simulation Techniques

As computational power increases, you can improve your Monte Carlo simulation techniques by integrating machine learning algorithms to detect complex patterns in data.

Experimenting with parallel computing can significantly speed up simulations, allowing for a broader range of scenarios and increased iterations for more comprehensive backtesting.

Remember that Monte Carlo Simulation is a powerful yet fallible tool, and your results are subject to the validity of your assumptions and the scope of your data.

Stay informed about the latest advancements in simulation techniques to keep your backtesting robust and informative.

Conclusion

Adding a Monte Carlo Simulation protocol to your backtesting process is an easy way to get a grasp on how risky your trading strategies are.

Since backtesting will only ever give you one result per market and timeframe, randomizing your trades with a Monte Carlo Simulation will effectively give you hundreds, or even thousands of backtesting sessions, with the same trading strategy and the same historical data.

This will allow you to see how much variance there is between each simulation and what  your maximum drawdown could be, in a worst case scenario.

You can also do Monte Carlo Simulations on your live trading results.

It's a very powerful tool that should be in the toolbox of every trader.  

 

The post Monte Carlo Simulation in Backtesting: Why All Traders Need It appeared first on Trading Heroes.

]]>
Backtesting vs Forward Testing: Differences and Benefits https://www.tradingheroes.com/backtesting-vs-forward-testing/ Wed, 10 Apr 2024 05:35:03 +0000 https://www.tradingheroes.com/?p=1025404 Many new traders skip either backtesting or forward testing, or both. Learn why both of these processes are necessary.

The post Backtesting vs Forward Testing: Differences and Benefits appeared first on Trading Heroes.

]]>

In trading, backtesting and forward testing are essential methods for evaluating the potential success of trading strategies.

Backtesting allows traders to assess how a strategy would have performed in the past by simulating trades with historical data. Unlike backtesting, forward testing involves trading a strategy in real-time with live data in a demo account, without risking real money.

These often seem like optional steps to newer traders, or an either/or scenario.

But in this article, I'll show you why they are both necessary in the development of trading strategies and cannot be skipped.

Defining Backtesting and Forward Testing

Backtesting results graph
Report from NakedMarkets

Backtesting

This is a technique used to test your trading strategy using historical data.

The image above is an example of a backtest that I did recently.

In essence, you are seeing how your strategy would have performed in the past.

By analyzing historical market data, you can identify patterns and assess the potential profitability of your strategy without risking real money.

What worked in the past is generally likely to work in the future.

A perfect example of a successful hedge fund that has done extensive backtesting is Renaissance Technologies.

Their unique mathematical models and extensive backtesting have made them extremely successful.

Forward Testing

Also known as paper trading this involves testing your strategy in real-time, with live data.

However, instead of committing real money, you simulate trades to predict how your strategy performs in current market conditions.

This method allows you to assess the practicality and adaptability of your strategy, when faced with market dynamics and volatility.

You'll also find out if your strategies fit your personality and schedule.

Here's a quick comparison of the 2 methods:

Aspect Backtesting Forward Testing
Data Used Historical market data Live market data
Purpose To test strategy effectiveness based on past data To test strategy effectiveness in real-time
Risk No financial risk, simulation software is used No financial risk, a demo account is used
Time Frame Can be conducted quickly Takes place over actual time, usually slower

Both backtesting and forward testing play crucial roles in the development of a successful trading strategy.

Through backtesting, you gain a historical understanding of your strategy's performance, while forward testing offers a real-time perspective.

It's important to go through both processes to ensure that you've been thorough in your testing. 

Purpose and Goals

Outdoor trading office

Backtesting and forward testing each serve a specific function in the trading strategy development and validation process.

Here's a more detailed look at each one and what they will help you with.

 

Purpose of Backtesting

Backtesting is a method used by traders to evaluate the potential of a trading strategy by applying it to historical data.

This process helps in understanding how a strategy would have fared in the past, allowing for adjustments and optimization before deploying it in live markets.

By identifying potential weaknesses and strengths, backtesting reduces the risk of future losses and improves the likelihood of success.

It also enables the testing of various parameters, conditions and ideas to fine-tune strategies for maximum effectiveness.

Furthermore, backtesting provides insights into the risk and return profile of a strategy, helping in managing expectations and investment decisions.

Through this method, traders can gain confidence in their strategies, ensuring they are well-prepared for a wide range of market conditions.

Purpose of Forward Testing

Forward testing, also known as paper trading, involves applying a trading strategy in real-time markets without using actual capital.

This technique allows traders to evaluate a strategy's performance under current market conditions, offering insights into its practical viability and effectiveness.

Forward testing helps in identifying any unforeseen flaws or areas for improvement in a strategy that might not have been apparent during backtesting.

It bridges the gap between theoretical backtesting results and actual trading, providing a more realistic assessment of how a strategy performs.

This method also enables traders to familiarize themselves with the strategy's mechanics in a live market environment.

For example, your strategy may have been very profitable in backtesting, but you may discover in forward testing that you don't have the time to manage the trades.

If that is the case, then you might find that you have to go back to the drawing board and create a strategy on a longer term chart.

By mitigating the risk of significant losses through virtual trading, forward testing is an essential step in validating and fine-tuning a trading strategy before committing real capital.

Methodologies

In trading system evaluation, proven procedures for backtesting and forward testing are essential for getting usable data.

Backtesting Process

Here are the steps that are required to do a backtest.

For a more detailed description, read the complete guide.

Before you implement these steps, be sure that you have already selected a market, timeframe and trading strategy that you want to test.

1. Choose a software platform and download historical data: Begin by choosing a backtesting platform and downloading historical market data, which includes prices, volumes, and other relevant information.

This is available on most backtesting platforms.

You want your backtesting data to go as far back as possible.

2. Strategy coding: For an automated strategy, encode your trading strategy into a software application that can execute the strategy.

If you're using a discretionary strategy, create a written trading plan.

3. Backtest: Run the strategy against the historical data to simulate trading results.

4. Analysis: Review the results.

Remember that there are no “perfect” results.

You have to determine what your goals are and if a strategy meets your goals.

Here are key metrics to focus on:

Metric Purpose
Net Profit Measures the total profit or loss.
Consistency Create a graph of the account balance to see how consistent the strategy is over time.
Win Percentage Number of wins divided by total number of trades.
Win/Loss Ratio Average profit in dollars divided by average loss in dollars.
Maximum Losers in a Row The worst losing streak you'll have to endure.
Maximum Drawdown The largest drop from an all-time high in account balance.
Sharpe Ratio Assesses the risk-adjusted return.

5. Optimization: After the initial simulation, you may find that your results do not meet your goals.

This is common.

If that's the case, optimize your strategy by adjusting the parameters and retesting.

6. Validation: Once you have a strategy that you're satisfied with, validate the strategy by applying it to out-of-sample data.

Repeat this process as many times as necessary until you have a trading strategy that you're satisfied with.

After your strategy passes the steps above, you're not done yet.

This is where most new traders stop.

But not you.

Now it's time to go through the forward testing process.

Forward Testing Process

1. Setup a demo/paper trading account: Create a demo account to simulate transactions using real-time data, without committing real capital. Many brokers and trading platforms have this option available at no cost. You can also use a simple notebook or spreadsheet to record your trades.

2. Account sizing: Select an account size that will be similar to the amount of risk capital that you'll use once you have a strategy that's completely tested.

3. Execute trades: Setup your charts like you did in your backtesting and start taking demo trades.

Use the same code for an automated strategy or your trading plan for a discretionary strategy.

4. Analysis: Review the results and see if they meet your goals.

It will probably take some time to compile enough meaningful data, so be patient.

5. Iteration: Based on the live performance data, make tweaks to the strategy and revert to backtesting to check these adjustments.

6. Expansion: If the strategy shows similar results to backtesting, you may consider starting to trade it with real money.

It's generally a good idea to increase the size of a live account gradually, while maintaining the same risk management.

It may be beneficial to start backtesting the strategy in other markets and on other timeframes at the same time.

Repeat the process of backtest, optimize, forward test, optimize, until you have enough strategies to meet your income goals.

Advantages and Disadvantages

Trader backtesting at computer

When you consider using backtesting and forward testing for your trading strategies, it's important to understand the unique benefits and potential drawbacks of each one.

They are complementary, so while they do have overlapping benefits, they test entirely different things.

Pros and Cons of Backtesting

Pros:

  • Quick Results: You can conduct backtesting relatively quickly because it uses historical data. Manual backtesting can be slow, but it's significantly faster than learning in real-time. Automated backtesting is very fast and can give you results in just a few minutes.
  • Cost-Efficient: No real money is at risk while testing historical scenarios. Backtesting software is also very affordable and some solutions are even free.
  • Confidence Building: A successful backtest will give you the initial level of confidence that your strategy works. If you don't have a minimum level of confidence, you'll always second guess yourself in live trading because you have no proof that your strategy has an edge.

Cons:

  • Overfitting Risk: Backtesting can lead to strategies that are overly optimized for past data but may not perform well in future markets.
  • Human Error: It's possible to make mistakes when backtesting. When testing an automated strategy, there can be errors in the coding or logic of the strategy. In discretionary backtesting, it's possible to make errors in interpreting the rules or changing the rules in the middle of a test.  Not accounting for normal trading fees can also lead to unrealistic results.
  • Not Real Time: Since you're not trading in real-time, it won't factor in time stress.

Strengths and Weaknesses of Forward Testing

Strengths:

  • Real Market Conditions: Forward testing your strategy exposes it to current market conditions, which are not available with historical data.
  • Psychological Preparedness: You get a better sense of how you'll react emotionally to real-time market movements.
  • Cost-Efficient: Many brokers and trading platforms offer free demo accounts for you to practice. Since no money is on the line, you're free to make mistakes without losing money.

Weaknesses:

  • Time-Consuming: It can require a substantial amount of time to gather enough data for analysis.
  • Loss of Focus: Since trades don't setup as frequently as in backtesting, it can be easy to lose focus.
  • Doesn't Simulate Stress of Loss: Since real money is not on the line, the psychology is a little different from real-money trading. If you want to better simulate real trading conditions, consider forward testing in a very small live account.

Backtesting vs Forward Testing: Which One is Better?

Both trading backtesting and forward testing serve critical but different roles in strategy development.

This does not make one necessarily better than the other.

They are complementary.

Backtesting provides a first insight into a strategy's historical performance, allowing for rapid iterations and adjustments, without financial risk.

It helps identify potential strengths and weaknesses over a wide range of market conditions in the past.

However, it might not account for all real-world variables, such as liquidity issues or slippage, leading to potentially over-optimistic results.

Forward testing, on the other hand, offers a more realistic view of how a strategy performs under current market conditions and can highlight issues not apparent in backtesting.

While it's more time-consuming and requires patience, it helps validate the real-world performance of a strategy.

Ultimately, the most effective approach combines both methods, using backtesting for initial strategy development and refinement, followed by forward testing to confirm its real-world viability.

What is the Difference Between Backtesting and Out-of-Sample Testing?

In a nutshell, out-of-sample testing is a subset of backtesting and it used to validate the backtesting results with historical data that was not used in the original backtest.  

Using out-of-sample testing and backtesting are both methods used to evaluate trading strategies, but they differ in the data they utilize.

Backtesting involves running a strategy against historical data to assess its performance.

In contrast, out-of-sample testing evaluates the strategy's effectiveness on a separate set of data not used during the development phase, offering a more unbiased measure of its real-world applicability.

This can be accomplished by using only part of the available historical data for backtesting and optimization. Once a strategy works well in backtesting, it can be further backtested on the rest of the data that was not used in the initial backtesting and optimization process. 

While backtesting helps refine and optimize a strategy, out-of-sample testing provides a crucial check against overfitting, ensuring the strategy can perform well under previously unseen market conditions.

Again, both methods are complementary, with backtesting focusing on strategy development and optimization, and out-of-sample testing emphasizing validation.

Conclusion

So that's the difference between backtesting and forward testing and why it's important to do both.

Many aspiring traders skip both of these steps and that's why over 90% of traders fail.

When you do both steps, you'll have a very high level of confidence that your strategies work and will be less likely to hesitate when taking trades.

To get started, be sure to read my backtesting and forward testing guides.

 

The post Backtesting vs Forward Testing: Differences and Benefits appeared first on Trading Heroes.

]]>
Backtesting Limitations (Manual and Automated) https://www.tradingheroes.com/backtesting-limitations/ Tue, 09 Apr 2024 00:34:12 +0000 https://www.tradingheroes.com/?p=1025402 Learn the limitations of both automated and manual backtesting. Also discover tools and techniques that will help you overcome them.

The post Backtesting Limitations (Manual and Automated) appeared first on Trading Heroes.

]]>

Backtesting is the best way to verify that a trading strategy has an edge and optimize that strategy to meet your goals.

Despite its importance, backtesting does have its limitations.

The primary constraints of manual backtesting are that it requires discretionary input from the trader and is not highly scalable. Automated backtesting is limited by the quality of the code and it lacks flexibility. 

I've been backtesting since 2008 and it has helped me tremendously and has helped countless traders that I've met over the years.

My goal in this article is to help you understand the details of the limitations of the backtesting method you use, so you can minimize the negative impact they can have on your results.

These limitations apply to backtesting trading strategies in any market.

Alright, let's get into it…

Limitations of Manual Backtesting

Manual backtesting involves a trader simulating a trading strategy on historical data by manually checking whether each trade would have been a success or a failure according to the strategy's criteria.

This process requires the trader to scroll through past market data, apply the trading strategy rules, and record the outcomes of each hypothetical trade.

There are many software solutions that can dramatically speed up this process, or a trader can choose to simply record their results on a spreadsheet.

Here are the limitations of manual backtesting that you need to be aware of.

Human Discretionary Bias

Trader backtesting at desk

Arguably, the biggest limitation of manual backtesting is that human bias is introduced into the backtesting process.

This is not necessarily a bad thing however.

The benefit to manual backtesting is that it can test discretionary trading strategies, of which there are many more than automated strategies.

So if you backtest manually, the key to success is applying your logic consistently.

Even though you are making discretionary decisions, do your best to understand what a good trade looks like.

But even the most diligent trader will have some variability in their backtesting, so it's important to test the same strategy several times before trading it live.

It's also worth noting that since there is individual discretion in manual backtesting, results can vary greatly between traders.

Therefore, it's always best to test a strategy for yourself and not rely soley on the results of others.

Relatively Slow Process

Low speed

A big downside of manual backtesting is that it's inherently time-consuming.

You must painstakingly go through historical price data, applying a strategy's criteria to determine entry and exit points.

This process is not only slow but also prone to errors, as it relies heavily on your attention to detail and patience.

So when backtesting manually, it's important to focus on testing one strategy at a time.

The upside to this slower process is that you get a more detailed look at each trade and that can help you develop new optimizations faster than with automated backtesting.

Not Scalable

Since manual backtesting is slow, it cannot be scaled efficiently.

As traders seek to validate their strategies across different instruments, timeframes, and market conditions, the manual process becomes exponentially more cumbersome.

So if you're going to backtest manually, you have to be resigned to the fact that you'll only be able to test a few markets and timeframes at a time.

But this can be a blessing in disguise because it will allow you to become an expert in a few core markets, instead of a generalist in many markets.

Risk of Overfitting

Super profitable trading strategy

The second major limitation is the risk of overfitting.

Overfitting occurs when a strategy is too closely tailored to past data, making it perform exceptionally well on historical data but poorly in real-world trading.

Manual backtesting, with its reliance on subjective judgment, increases the risk of introducing biases into the testing process.

You may unconsciously select data that confirms the strategy's effectiveness or overlook data that contradicts it.

This selection bias can lead to over-optimistic results that do not accurately reflect the strategy's real-world performance.

Therefore, it's important to test your strategies on as much historical data as possible and not “cherry pick” the best performing periods.

Potential Miscalculations

Real-world trading involves factors such as slippage, transaction costs, and varying liquidity, which can significantly impact the profitability of a strategy.

Manual backtesting can oversimplify these aspects and make strategy look much more profitable than it really is.

Without a realistic representation of market conditions, the results of manual backtesting can be misleading, painting an inaccurate picture of a strategy's potential success.

To overcome this, always check that you're using realistic settings for things like commission, spread and slippage.

If these things are hard to factor in, you can always manually lower the return of your strategies slightly to account for unknown variables.

Limited Complexity

Another critical limitation of manual backtesting is the difficulty in testing complex or quantitative strategies.

If you're going to backtest discretionary trading strategies, you have to stick to methods that are simple and easy for you to calculate and execute.

Manual backtesting is not suited to handle high-frequency trading strategies or those that rely on complex analysis.

Although it may seem appealing to execute super complex, uber clever strategies, in my experience it's often the simple strategies that do best.

Limitations of Automated Backtesting

Automated or programmatic backtesting has revolutionized the way traders develop and evaluate their strategies, leveraging historical data to predict future performance without manual intervention.

By simulating trades based on specific criteria and algorithms, this method offers efficiency, precision, and the ability to test complex strategies across multiple datasets and timeframes.

Despite these advantages, automated backtesting is not without its limitations, which can impact the reliability of the results and the ultimate success of trading strategies.

Overfitting Risk

Office with blackboard and math equations

One of the primary challenges with automated backtesting is the risk of overfitting.

Overfitting occurs when a model is excessively complex, with numerous rules or parameters that are tailored to perform exceptionally well on historical data but fail to perform in the future.

This phenomenon leads to inflated backtest performance that cannot be replicated in live trading.

An example of this is the story of LTCM (Long-Term Capital Management), a hedge fund that relied heavily on complex mathematical models.

Despite the brilliance of its team, which included Nobel laureates, LTCM folded in 2000, due to a combination of excessive use of leverage and strategies that were overfit to past market conditions.

Look Ahead Bias

Another significant limitation is the “look-ahead” bias, which occurs when a strategy inadvertently utilizes future information in its trading decisions, leading to unrealistic backtest results.

This can happen through programming errors or when the data set includes future data not available at the time of trade execution.

The illusion of extraordinary returns generated by such biases can be misleading and result in substantial losses when the strategy is applied in real-time trading.

Trading Fees Miscalculation

Trading fees also present a hurdle for automated backtesting.

Historical data may not fully capture the market's liquidity, bid-ask spreads, and slippage that can significantly affect transaction costs and execution.

Automated backtests often assume ideal trading conditions, neglecting these real-world trading expenses.

This oversight can lead to an underestimation of costs and an overestimation of strategy performance.

Lack of Human Input and Intuition

Furthermore, the absence of human intuition and experience is a notable drawback of automated backtesting.

While automated systems excel in processing vast amounts of data and executing predefined strategies, they lack the ability to interpret nuanced market signals or adjust to unforeseen events.

In other words, they are only able to run the instructions they are given.

Famous traders like Jim Simons, the founder of Renaissance Technologies, have successfully combined automated trading with human oversight.

Simons, a mathematician, and his team developed sophisticated algorithms that have consistently outperformed the market.

However, the success of Renaissance Technologies also relies on continuous refinement of its models and the expert judgement of its team, highlighting the importance of blending automated strategies with human insight.

Technology Risk

Computer next to window

The dependence on technological infrastructure can pose serious risks.

Once an automated strategy is backtested, live trading requires robust computing resources, stable internet connectivity and continuous human oversight.

Since computer programs only follow instructions they are given, if certain scenarios are not accounted for, any failure in these systems can lead to significant losses, especially with high-frequency trading strategies.

One example is what happened to Knight Capital Group in 2012.

A glitch in their computer programs caused them to amass huge losses and almost sent them into bankruptcy.

Final Thoughts on Backtesting Limitations

Even though there are limitations to both manual and automated backtesting, there's no doubt that some sort of backtesting has to be done to verify and optimize trading strategies.

Risking real money on an untested strategy is like hiking in the mountains without a map.

You don't know a proven path, you're very likely to get lost on your hike and maybe not even make it back.

Therefore, the solution is to pick the backtesting method that best suits your skills and goals.

Then understand the limitations of your chosen method and minimize the negative impact of its limitations.

If you want to learn the tools and techniques for backtesting both manual and automated trading strategies, continue reading my tutorial on how to backtest a trading strategy.

 

The post Backtesting Limitations (Manual and Automated) appeared first on Trading Heroes.

]]>
How to Backtest a Trading Strategy in Any Market https://www.tradingheroes.com/how-to-backtest-a-trading-strategy/ Sat, 06 Apr 2024 05:06:10 +0000 https://www.tradingheroes.com/?p=1023943 Learn how to backtest a trading strategy and choose the best strategy for you. Get the tools, tips and techniques that pros use.

The post How to Backtest a Trading Strategy in Any Market appeared first on Trading Heroes.

]]>

Backtesting is the systematic process of finding out if a trading strategy has worked in the past and therefore will be very likely to work in the future. 

This is the most important step that a trader can go through to prove that their trading strategy actually works.

Yet, so many aspiring traders miss this vital step.

The best part about backtesting is that you don't necessarily need to know how to code to backtest.

There are many fantastic options for coders and non-coders alike.

So if you want to skip the pain of years of losing trades and blowing out accounts, keep reading to learn how to backtest a trading strategy in any market.

When you buy something through one of the links on our site, we may earn an affiliate commission.

Trading desk

Does Backtesting Really Work?

In my own personal experience and from reading the experiences of hundreds of traders since I started this website in 2007, the answer is a resounding YES.

But don't take my word for it.

Watch my interviews with professional traders who have gone on to manage funds and trade full-time for themselves.

Here's an example of one of my interviews.

In addition, there are countless trading books that prove that backtesting is the best way to master a trading strategy.

Think of it this way, would you buy a used car without test driving it first?

Of course not.

You need to test it out to see if it actually runs, if the air conditioner works, and that there aren't any weird noises.

So in a similar way, you need to take a trading strategy for a “test drive” and find out its strengths and weaknesses.

But there are many more benefits to backtesting.

The Benefits of Backtesting

Here are the main benefits that you'll get out of backtesting a trading strategy.

They are all very important for building your skills, proving that a strategy has an edge in the markets and optimizing a strategy.

Performance Assessment

Backtesting allows you to evaluate the effectiveness of a trading strategy by providing statistical data on its past performance, such as win rate, average profit per trade, drawdowns, and overall profitability.

It offers a risk-free environment to evaluate the potential of a strategy.

By analyzing historical data, you can gain insights into the strategy's return on investment (ROI) and risk profile.

This is particularly valuable in identifying which strategies are likely to be profitable and which are not, enabling you to make informed decisions about where to allocate your resources.

Risk Management

Worried man

Risk is one of the most important things to manage in trading.

A thorough backtest will provide the following information about the risk profile of a trading strategy:

  1. Understanding Risk/Reward Ratios: It helps in understanding the risk/reward ratio of a strategy by quantifying potential losses and gains. You can see not just the profitability but also how much risk is being taken to achieve that profit.
  2. Exposure to Market Conditions: Backtesting exposes a strategy to various market conditions, including high volatility periods, market downturns, and bull markets. Understanding how a strategy performs under these conditions helps you manage risk by knowing when a strategy might not perform well.
  3. Setting Risk Management Parameters: Based on backtesting results, you can set stop-loss orders, take-profit levels, and position sizes that align with your risk tolerance and capital preservation goals. This ensures that trades are exited at predetermined levels to minimize losses or protect profits.
  4. Statistical Analysis: It provides statistical measures of performance like the Sharpe ratio, drawdowns, and win rates. These metrics are essential for assessing the risk-adjusted returns of a strategy.
  5. Risk of Ruin: This shows how likely a strategy is to have a large drawdown or blow out the entire account.

Strategy Optimization

You can use backtesting to fine-tune your strategies by adjusting different parameters and rules to improve performance and adapt to different market conditions.

Through backtesting, you can identify the optimal settings for your strategy, such as stop-loss orders, entry and exit points, and position sizing.

Adjusting these parameters based on historical performance can help in refining a strategy to achieve higher returns or to minimize risk.

Confidence Building

Doubt is the kiss of death in trading.

A well-backtested strategy can give you confidence in your approach since you have historical evidence that your strategy has been profitable in the past.

If you don't have confidence in your trading strategy, you'll mess with good trades unnecessarily and you'll probably skip many profitable trades altogether.

Just like any great athlete has confidence in their skills, traders need to build confidence in their strategies to be successful.

When you've seen a setup hundreds of times in backtesting, taking a trade becomes a no-brainer because you know what a good trade looks like.

Identifying Market Conditions

A common question from new traders is: How do I know that the market is in a trend?

Well, you learn to identify any market condition through backtesting.

This could be a ranging market, trending market or anything else.

Once you've seen a particular type of market many times, you'll get a feel for what it looks like.

Reducing Overfitting

When you backtest a trading strategy over a wide range of historical data, you can identify if the strategy is overfitted to a specific period or set of conditions.

A robust strategy should perform well across different timeframes and market environments.

One common backtesting mistake that many traders make is they only backtest and optimize their strategy over a short period of time.

Then they try to trade it in current market conditions and they wonder why it doesn't work.

The reason that it doesn't work is because the strategy was optimized over, say 1 year, but that could have been an unusually good period for that strategy.

Over the entire history of that market, that could have been the absolute best time for that strategy.

I've personally seen this happen.

So if they try to trade that strategy at any other time, it will fail miserably.

Backtesting over a long historical period ensures that a strategy is robust enough to work in many different types of markets.

Save Time, Money and Reduce Stress

Clock on wall

Backtesting is much faster than waiting around for the markets to print candles in real time.

You can get decades worth of backtesting trades in as little as a few minutes.

Testing also allows you to evaluate a strategy without risking real capital.

More importantly, backtesting will save you the headache of jumping from strategy to strategy, while losing money along the way.

So even though it can be exciting to jump into real-money trading right away, that's always the longer route to success.

Backtesting first will seem longer initially, but is actually a shortcut. 

Emotional Discipline

Adhering to a strategy that has been rigorously backtested will make it easier to stick to your plan and make less impulsive decisions.

By testing and adhering to strategies that have shown promise in historical simulations, you'll avoid taking random, unproven trades based on emotions or market volatility.

This disciplined approach is crucial in maintaining consistency and achieving long-term profitability.

Types of Backtesting

There are 3 types of backtesting.

They will all get you a similar result, but the route you take to get that result will be different.

Each one has its benefits and downsides, so don't get too hung up on being able to do fully automated backtesting right away.

It sounds sexy.

But in reality, most people do better learning how to manually backtest first, then moving up the scale to automated backtesting…if they are so inclined.

Manual Backtesting

I feel that this is the place where most traders should start.

It's easy and anyone can do it.

Moreover, manual backtesting allows to you get very “intimate” with the data and every single trade.

In other words, you can see what each trade is doing on a very granular level and that can make it much easier to spot potential optimizations and errors.

Another benefit of manual backtesting is that most trading strategies cannot be fully automated.

There is often an element of discretion in most trading strategies, and therefore you'll have a lot more flexibility with manual backtesting.

You can use almost any trading platform to do manual testing, provided it has enough historical data.

Here's an example of a way that you can do manual backtesting for free.

Semi-Automated Backtesting

An intermediate step that not a lot of people talk about is semi-automated backtesting.

This is when you create scripts or automations that only manage part of your strategy, like the entry, the exit or the trade management.

Semi-automation allows you to speed up the backtesting process dramatically, while still being able to use the discretionary elements of a strategy.

It's a great compromise between manual and fully automated.

There are many ways to do this, but this example will get you started.

Automated Backtesting

Now we jump into fully automated backtesting.

To get the most out of this method, you'll probably have to learn how to code.

Learning to program will give you the most flexibility and allow you to control every aspect of a backtest.

There are no-code ways to do automated backtesting, but they do have their limitations.

Again, this reduces the number of strategies you can backtest because not all strategies can be turned into computer code.

Another downside is that it can be tough to see potential issues with a strategy because you aren't seeing every single trade on a chart.

But if you're a developer or engineer, this option might be very appealing to you.

There have been many successful automated traders, so don't let those facts discourage you.

The Turtles are a good example of very successful traders who use automated strategies.

How to Backtest a Trading Strategy Step-By-Step

Regardless if which method you use to backtest a trading strategy, the process is always going to be the same.

These are the steps to do your first backtest.

Step 1: Pick One Market and Timeframe

There is a misconception among many new traders that a trading strategy will work equally well in any market and on any timeframe.

Not true.

So it's best to pick one market and timeframe that you'll master, before moving on.

How do you pick the best ones?

That's a very individual choice.

There's no “best” trading market or timeframe for everyone, only the ones that you're most comfortable with.

So take some time to learn about different markets and pick the one that appeals to you the most.

Backtesting on the 4 hour chart or higher is fairly straightforward.

But day trading strategies are a little more involved so learn the details here.

Step 2: Learn Trading Strategies for Your Market

There are countless posts on forums like Reddit that show a chart and ask: Is this a good trade?

That's always painful to read because it's obvious that the person doesn't know anything about trading strategies.

Just like basketball players have their favorite moves for getting the ball in the hoop, traders need to have their favorite trading strategies to extract profit from the markets.

The fastest way to find a trading strategy to test is to see what successful traders are doing in the market you've selected.

Like with choosing a market, choosing a trading strategy will be very individualized to you.

Find a strategy that makes sense to you and that looks easy to test.

It also helps to adopt a curious mindset.

Many times traders can get too wrapped up in finding the most profitable strategy.

I've certainly been there.

But if you approach strategy selection from the standpoint of having a feeling that a strategy will work, and being genuinely curious about the results, I believe that you'll get much further than if you just look for maximum profit.

Step 3: Create a Complete Trading Plan to Backtest

Journaling at night

Once you have a general strategy idea, it's time to turn that into a complete trading plan.

It helps a lot to write that plan down because you can reference it throughout your backtesting sessions.

When you don't have a written plan, it's too easy to stray from the plan and take random trades.

If you take random trades, you won't know how well your plan really works.

Define every element of your plan like:

  • Entry criteria
  • Exit criteria
  • Trade management criteria
  • Risk per trade
  • When you trail your stop loss or move it to breakeven
  • Maximum number of open trades at the same time
  • If you're going to take trades in correlated markets or not

An easy way to get started is to download my free trading plan worksheet.

Step 4: Choose Your Software and Get Historical Data

Backtest a trading strategy with NakedMarkets

Before you start testing, make sure that you have access to a lot of historical data for your chosen market.

At least 20 years of data is a good place to start.

This will determine which backtesting software or programming language you'll use.

I provide some software suggestions in the next sections.

The best software for you will depend on the market your trading.

But for now, just know that you have to test your trading plan in some sort of software platform.

You can also download historical data from third party data providers and upload it to your software.

So if you like a software solution, but it doesn't have enough data, just know that this option is available.

Step 4: Backtest

Backtesting computer

Alright, now it's time to backtest!

Start up your backtesting software and take trades according to your plan.

Most backtesting platforms will have instructions on how to do your first test.

Obviously I cannot list instructions for every single platform and programming language out there because it would make this article way too long.

So it's up to you to find the instructions for your platform.

Many people also make tutorials on YouTube, so that's another great resource.

When backtesting on the 4 hour chart or higher, then backtest with all of the data you have available.

That's fairly straightforward.

The shorter timeframes are a little harder to test.

It's not always possible to backtest all of the data because there is just too much to backtest.

In this case, pick a few different market conditions like:

  • Ranging markets
  • Strongly trending markets
  • Weakly trending market
  • Highly volatile markets

It helps to zoom out to a higher timeframe to see these types of markets.

For example, if you're backtesting on the 15 minute chart, zoom out to the 4 hour chart to see the overall market conditions.

Then within each of those periods, test a couple of years.

These “spot checks” will give you a good idea of how your strategy performs under different market conditions and if you should continue testing or not.

If your results are favorable, then you can do more in-depth backtesting.

Step 5: Review the Statistics

Trading strategy results.

When you have completed a full backtest, review the results to see if the strategy has potential.

You can use a simple Excel spreadsheet to do your calculations.

Even better, if the software you're using has built-in analytics, that will save you a lot of time.

What you're looking for will depend on your goals.

Some traders look for total return, others look for consistency, and others value low risk.

Ask yourself what you value most and make that your goal. 

Step 6: See if the Results can be Optimized

Backtesting results graph

Spoiler alert: Most backtests will have mediocre or losing results.

But don't get discouraged.

Almost all trading strategies will have to be tweaked and optimized to work well. 

That's the nature of the beast.

So be willing to experiment and try different ideas. 

Here are some ideas for optimizing the results of your strategy:

  • Experiment with different indicator settings
  • Trail your stop loss
  • Target a smaller profit target
  • Target a larger profit target
  • Split your profit targets
  • Tighten your stop loss
  • Make your stop loss larger
  • Add an additional indicator or criteria to enter or exit
  • Don't trade on days or at times that have a high percentage of losses

Just be careful of over optimizing a strategy.

This is when you make a trading strategy work very well for the backtesting period, but it doesn't perform well in other periods.

To avoid this, it helps to split your data up into in-sample and out-of-sample data.

In other words, leave some data out of your optimization process so you can backtest on it to see if your strategy will work well in a period that hasn't been optimized for.

For example, let's say that you have 20 years of data on the daily chart.

You could backtest and optimize on 15 years of data.

Then see how that strategy works on the remaining 5 years of data that you didn't optimize for.

This is easier to do on shorter timeframes because there is much more data.

Doing this one extra step can help you understand how well your strategy will work in the future.

Step 7: Decide to Keep or Trash the Strategy

trash can

Once you've done all of the potential optimizations you can think of and the strategy still isn't as profitable as you would like, then it's time to trash the idea and move on.

That's usually very obvious.

What isn't as obvious is when a strategy is slightly profitable.

If that's the case, then test the trading strategy on multiple timeframes and multiple stocks, futures contracts or currency pairs.

Adding more trading opportunties can create a more favorable return.

You might also consider trading a portfolio of different strategies.

Each one on its own might not have a fantastic return.

But when traded together, they could be very profitable.

Backtesting in Different Markets

Each trading market has its own nuances and best practices when it comes to backtesting strategies in that market.

So now I'll give you the benefits and downsides to each market.

I'll also provide some tools and tips that can help you backtest more efficiently in each market.

Backtesting in Forex

In my experience, Forex is the easiest market to backtest.

There are only a set number of markets and some currency pairs have a long history.

The data is also easy to get and usually pretty clean.

It's also the most liquid market in the world, so there's very low slippage.

Transaction costs are also low on the major pairs.

My favorite backtesting software is NakedMarkets because it has free updated data and I can build semi-automated and fully automated strategies with the no-code interface.

Backtesting Indexes

Indexes like the S&P 500 are also easy to backtest because they have one continuous chart that goes back a long time.

To trade indexes, you can use futures, ETFs, or any other product that tracks an index.

Ease of backtesting will vary depending on which derivative you trade, but they can be a great market to trade.

I've seen some traders make a very good living just trading the S&P500 E-mini.

Great backtesting platforms are TradeStation, NinjaTrader or NakedMarkets.

Backtesting Stocks

Bull on Wall Street

Stocks are harder to backtest than other markets because there is a huge universe of individual stocks listed on any stock exchange.

I'm also going to group ETFs into this category because they are traded in a similar way to stocks.

On the upside, there are always many trading opportunties because there are so many stocks available to trade.

I use Amibroker, but there are many other platforms out there like TradeStation.

You can also do automated backtesting with programming languages like Python.

Backtesting Futures

Like in Forex, futures are fairly easy to backtest because there are a limited number of markets.

The biggest downside is that futures contracts expire, so there will always be a slight “jump” in the data when there is a contract change.

On top of that, you can trade different expiration months in the same contract, which can create some confusion.

Therefore, the easiest way to backtest futures is to find data that uses a continuous chart of the front month, or the contract that is going to expire the soonest.

This is usually the most liquid contract, making it less likely that you'll get choppy price action and unreliable backtesting results.

It can also help to backtest each contract individually to eliminate some of the discrepancies that can come when one contract expires and the next contract kicks in.

I've tried to backtest futures, but I found it too frustrating to navigate the contract changes.

However, there are obviously many successful futures traders out there, so don't get discouraged if you really like this market.

The premier backtesting platform for futures is TradeStation, but there are many other ones out there like NinjaTrader.

Backtesting Crypto

Since crypto is an easy market to backtest, there are many software packages that can backtest this market.

The biggest downside is that crypto is a fairly new market, so you won't have much data to test with.

Therefore, you might be better off trading a lower timeframe, or using a scale in / scale out approach.

Many markets also don't have a lot of liquidity, so you're generally better off testing the major ones like Bitcoin, Litecoin and Ethereum.

An upside to backtesting crypto is that there are very noticeable boom and bust cycles, making it somewhat easier to build strategies around.

I suggest using NakedMarkets to backtest cryptocurrencies.

Backtesting Options

Backtesting options is much different from other markets because of the way the contracts are structured and how strategies are constructed.

I'm not an expert in options, so the information here is from my research and not personal experience.

One thing that makes options hard to backtest is that there are different types of options: vanilla, binary, one-touch, double no-touch, American, European, etc.

European vanilla options are the most common, so that's generally best to start there.

Since these options can only be exercised at maturity, it provides fewer variables in backtesting.

Popular backtesting platforms are tastylive and OptionAlpha.

How Far Back Should You Backtest a Trading Strategy?

Backtesting at laptop

The short answer is that you should backtest as far back as possible, and with as much data as possible.

You want to see how the trading strategy performed in as many market conditions as possible.

A common meme on the internet is that you need to backtest a minimum of 100 trades to prove that a strategy works.

That's a myth.

As I detail here, the amount of trades you need to prove a trading strategy will depend on the strategy and trading timeframe.

Final Thoughts on Backtesting

So that's how to backtest a trading strategy in any market.

Remember that there's no best strategy or market for everyone.

The best combination will depend on your trading personality and what you like best.

So don't look for the “most profitable” strategy and market.

Pick the ones that make the most sense to you.

Note: You may notice that I've left a popular backtesting tool off the list, TradingView.

fThis is a fantastic platform for doing many things, but backtesting is not one of them.

You'll need to buy their higher plans to get the Deep Backtesting feature, which gives you access to more data.

In my opinion, it's not worthwhile, at least at this point in time.

 

The post How to Backtest a Trading Strategy in Any Market appeared first on Trading Heroes.

]]>
How to Automate Backtesting of a Trading Strategy https://www.tradingheroes.com/automate-backtesting/ Fri, 29 Mar 2024 10:13:37 +0000 https://www.tradingheroes.com/?p=1025107 Learn how to automated backtesting of a trading strategy in any market and on any timeframe. Get the tools, techniques and more.

The post How to Automate Backtesting of a Trading Strategy appeared first on Trading Heroes.

]]>

In my experience, backtesting a trading strategy is an essential step before deploying it in the market.

It allows me to assess how the strategy would have performed in the past, giving me a clearer idea of its potential success in the future.

Manual backtesting is great, but automated backtesting speeds up the process considerably.

There are three ways to automate backtesting of a trading strategy: learn a programming language, use pseudocode software or use no code software. Each one has pros and cons that must be considered when choosing an automated backtesting method. 

So in this article, I'll explain each of the options and how to figure out which one is the best one for you.

Keep in mind that you don't necessarily need to learn programming to do an automated backtest, and this can be done in any trading market where sufficient historical data is available.

I'll also provide links to the best resources that I know of, based on my experience and research.

Let's get into it…

When you buy something through one of the links on our site, we may earn an affiliate commission.

Backtesting in office

Key Takeaways

  • Automated backtesting can be done even if a trader doesn't want to learn how to code.
  • Not all trading strategies can be fully automated. But in those cases, semi-automated backtesting can be extremely helpful.
  • There are many free and paid tools that can help traders of all skill levels get into automation.

Why Backtesting a Trading Strategy is Important

I've written many articles and tutorials on backtesting.

You can find them here.

But if you're new to the idea of backtesting, I'll give you the elevator version of why it's so important.

By utilizing backtesting software, I'm able to simulate years of trading within minutes, allowing me to test multiple strategies against a wide range of market conditions.

The software does the heavy lifting, executing my strategy across the selected time period and accumulating the results for my analysis.

What I look for in the backtest results is not just overall performance, but also how the strategy behaves during different market phases.

Whether the market is trending, ranging, or experiencing high volatility, I need to know that my strategy can handle these conditions.

The insights gained are invaluable.

They either prove that the strategy has a legit edge, or I go back to the drawing board to make improvements.

Why Automated Backtesting?

The bottom line is that automated backtesting helps me speed up the process of creating and optimizing profitable trading strategies. 

I first started backtesting with a simple chart and a spreadsheet.

That was fine in the beginning because there weren't the tools that are available now.

But it would take foreeeever to backtest just one market, even on the daily chart.

When I can automate backtesting, I can speed up that process dramatically and test multiple markets in a fraction of the time.

What many traders also miss is that they can do semi-automated backtesting. 

Since not all trading strategies can be 100% automated, semi-automated backtesting allows me to automate just the entry, for example.

Then I can use discretion to exit the trades.

Any aspect of a trading strategy that can be semi-automated, should be, because it saves a ton of time.

Benefits of Automated Backtesting

Automating the backtesting process offers efficiency and the ability to test numerous strategies across different timeframes and market conditions very quickly.

Many software packages will also provide detailed analytics on each backtest.

This allows me to focus on coming up with ideas and optimizing, instead of figuring out how to get these metrics in a spreadsheet.

The tools available nowadays can make this easy to do.

Limitations of Automated Backtesting

Despite its many benefits, there are limitations to automated backtesting.

One primary challenge is ensuring the historical data used is complete and accurate.

Any gaps or inaccuracies can significantly alter the test results.

There's also the risk of overfitting a strategy to past data, making it less adaptable to future live market conditions.

Another point to consider is simulation limitations, as models may not account for factors like market impact, liquidity, or real-time transaction fees.

Finally, not all trading strategy criteria can be completely programmed into a computer.

The First Step Before Backtesting

Hands writing in journal

Before you start backtesting with one of the solutions below, be sure that you have a trading strategy to test.

This means having a complete trading plan.

You need to have specific parameters for your entries, exits, risk and trade management.

Once you have a strategy to test, now it's time to pick a platform to help you do an automated backtest.

Automated Backtesting Software Tools

Before picking a robust backtesting framework, it's essential to understand your options.

So here are the 3 types of tools that are available, along with some resources in each category.

New solutions are constantly popping up, so use this list as a starting point in your exploration.

I'll update this list as frequently as possible, but it's up to you to find the best solution for your situation.

Learn a Trading-Friendly Programming Language

Trading at computer

To effectively develop and customize a trading algorithm, you must be fluent in a programming language commonly used by traders.

I haven't had the patience to learn a programming language myself, so I'm not an expert in this area.

But I have done quite a bit of research on the topic and here's what you need to know.

Benefits of Programming

  • There are highly mature languages that have been proven to work for trading
  • Many free tools available
  • The ultimate level of customization capabilities
  • You can build reusable blocks of code that you can use for future backtests
  • There is a large library of open source code and tutorials that you can use to get started quickly
  • Can be used in any market where historical data is available

Downsides of Programming

  • It can take time to learn how to code at a level that will allow you to create meaningful backtests
  • Creating simple things like performance graphs usually takes extra time to learn
  • One misplaced semi-colon can break the entire program and take extra time to find and fix

There are 3 programming languages that are frequently used by professional traders:

  • Python
  • R
  • C#

I'll give you a quick summary of each one and where you can go to get more information.

Python Programming Language

Python programming language

I personally know a couple of traders who build their trading strategies with Python.

It emphasizes code readability and allows programmers to express concepts in fewer lines of code compared to other languages.

Python supports multiple programming paradigms, including procedural, object-oriented, and functional programming.

It has a vast standard library and a thriving ecosystem of third-party packages.

Python's interpreted nature facilitates rapid development and debugging, making it popular among both beginners and seasoned developers.

Here are resources that will get you started with programming in Python: 

R Programming Language

R is a programming language and environment that is primarily used for statistical computing and graphics.

Perfect for trading.

It provides a wide variety of statistical and graphical techniques, including linear and nonlinear modeling, time-series analysis, and clustering.

R is open-source and highly extensible, with thousands of packages available for specialized tasks.

It is widely used in academia, research, and industry for data analysis, visualization, and machine learning applications.

R's syntax is designed to make data manipulation and analysis intuitive and efficient, making it a popular choice among statisticians and data scientists.

Here are some resources that will get you started with programming in R: 

C# Programming Language

C# is a versatile, object-oriented programming language developed by Microsoft as part of its .NET framework, designed to be simple, modern, and type-safe.

It's widely used for developing desktop applications, web services, and enterprise software, and it has extensive libraries that facilitate tasks ranging from database interaction to web development.

Traders use C# to program automated backtests by writing algorithms within trading platforms like WealthLab, or QuantConnect, which support C# natively.

They utilize the language's robust features to define trading signals, manage orders, and analyze historical data for performance evaluation.

The backtesting environment provided by these platforms allows for the simulation of trading strategies over past market data to assess their efficacy before live deployment.

Here are some R resources that will get you started with programming in C#: 

Now if programming isn't your cup of tea, then luckily there are other options out there.

Use Pseudocode Software

 

Pseudocode software serves as an intermediary solution between programming and no code software.

It's meant to be a little easier than traditional programming, but still give you more control and customization than the no code route.

There are many built-in shortcuts that are included in each platform, reducing the amount of code needed for each application.

I'm personally not a fan of these solutions either, because they are still too much like programming for my taste.

However, this is useful to some traders who want to automate their backtesting, without learning all the nuances of a true programming language.

So if you don't want to become a full-on programmer, then this might be a happy medium.

Benefits of Pseudocode Software

  • Easier to learn than programming
  • Usually more built in tools for things like graphs and statistical analysis
  • Less code needed when compared to traditional programming

Downsides of Pseudocode Software

  • Platform dependent, so your pseudocode will only work on one platform
  • You may not be able to do everything you can do with a regular programming language, since there isn't the same level of customization available

I've personally used 4 solutions:

  • Pine Script
  • MQL
  • EasyLanguage
  • AFL

Here's a summary of each of them and where to get more information.

The right one for you will depend on the platform you use and the market you trade.

MetaTrader / MQL

MetaTrader 5 website

MQL, or MetaQuotes Language, is a proprietary scripting language for developing trading robots, technical indicators, scripts, and function libraries for use with the MetaTrader software.

MQL4 is used with MetaTrader 4, while MQL5, its successor, offers more advanced capabilities and is used with MetaTrader 5.

Both versions of MQL are specifically designed for automated trading, strategy testing, and financial market analysis.

This is a very popular language that some people might consider a full-on programming language.

In my opinion, it falls more into the category of pseudocode because you don't need to include all of the elements that are required for a normal computer program.

It's fairly complex however, so it does take some time to learn.

Here are some resources that will get you started with MQL: 

TradingView / Pine Script

Pine Script is TradingView's platform-specific scripting language used for creating custom technical analysis indicators and strategies directly within its charting platform.

It's designed to be user friendly, allowing traders with minimal programming experience to design, test, and share their trading ideas and systems.

Pine Script enables the customization of charts and the creation of alerts based on specific trading conditions.

I've created a few custom indicators with Pine Script and it is easier than MQL.

Here are some resources that will get you started with Pine Script: 

TradeStation / EasyLanguage

EasyLanguage is a proprietary programming language used in the TradeStation platform for developing and backtesting trading strategies.

It's designed to be user-friendly and accessible to traders without extensive programming experience.

EasyLanguage allows traders to create custom indicators, strategies, and trading systems using a simplified syntax and built-in functions.

Here are some resources for learning TradeStation's EasyLanguage: 

Amibroker / AmiBroker Formula Language (AFL)

AmiBroker Formula Language (AFL) is a scripting language used in the AmiBroker trading platform to create custom indicators, trading strategies, and analytical tools.

This solution is primarily for stock traders.

AFL allows users to define and manage charts, scan for opportunities, and backtest trading systems with speed and precision.

It's designed to be easy to understand for those familiar with technical analysis and trading concepts, while also being powerful enough to implement complex algorithms.

Here are some resources for learning Amibroker's AFL:

Use No Code Software

Man at beach

No code backtesting software allows traders to test their trading strategies using a visual interface without writing any code, typically by selecting indicators, setting parameters, and defining rules through dropdown menus and form fields.

These platforms often provide a user friendly drag-and-drop or point-and-click environment to facilitate the creation and historical evaluation of trading strategies.

They aim to make backtesting accessible to those without programming skills, while still offering robust analysis and performance metrics.

Benefits of No Code Software

  • Extremely easy to use
  • Can start creating meaningful backtest very quickly
  • Some platforms have a wide range of trading strategy inputs to create many different strategies

Downsides of No Code Software

  • Lack the same level of customization that programming or pseudo coding provides
  • Some platforms are very limited in what they can do

I'll share my experience with 2 platforms, but do your own research because new ones are popping up all the time.

NakedMarkets

Automate backtesting with NakedMarkets

This is my favorite no code platform.

It has a ton of flexibility that I haven't seen before in a no code platform.

I can create fairly complex trading strategy logic with its intuitive drag and drop interface.

You can backtest Forex, stocks, indexes and more.

The detailed analytics suite also provides a ton of data on a backtest that you don't get in other platforms.

Everything can be backtested in the platform, so there's no need to export an EA or plugin to another platform for backtesting.

They are also working on an export feature that will export automated trading strategies to MetaTrader.

Check out the videos and tutorials below to get a feel for what the program can do.

You can also get a discount and a special offer on NakedMarkets here.

Here are some resources for learning NakedMarkets:

EA Builder

EA Builder is an online platform that allows traders to build MetaTrader 4 and 5 Expert Advisors (EAs), and TradeStation strategies, without coding.

The benefit is that the software will export the strategy that you build on the website to a file that you can import into MetaTrader or TradeStation.

I found that this helps a lot with very simple trading strategies.

But once you try to build more complex ones, the platform simply doesn't have the capacity to do that.

So if you're looking for something to build simple strategies and backtest them in MetaTrader or TradeStation, then this could be for you.

However, you should try their free demo first to see if this is a good fit for what you want to do.

Here are some resources for learning EA Builder:

Evaluating Backtesting Results

Automated backtesting results have to be evaluated a little differently than manual backtesting results.

The first thing I look for are potential errors in the logic of the trading strategy.

Since the trades are being executed automatically, I cannot see the trades in action.

So I have to double check that the trades look correct.

I do this by looking at the trades list and I spot check a few of the executions manually.

If that checks out, then here's what I look at:

  • Profitability: I not only look at the overall profit of the strategy, I also look at how consistent the strategies is on a yearly basis. A strategy can be profitable, but all of that profit could have come from just one month. I like to see steady growth over multiple years.
  • Win / Loss Ratio: I also take note of the win-loss ratio which indicates the proportion of winning trades to losing ones. A low ratio is not necessarily bad if the winners are much bigger than the losers, but I want to see if there is any room for improvement.
  • Drawdown: Understanding the drawdown of a strategy is vital. It involves assessing the largest peak-to-trough decline in my account balance. I calculate the maximum drawdown and if it's too large, it indicates potential high risk, and I should probably adjust my risk management approach.
  • Monte Carlo Simulation: I run a simulation over at least 100 simulations to get a good idea of the maximum potential drawdown.
  • MFE/MAE: These metrics show how much the trades went in my favor or went against me, while the trades were open. This can give me valuable clues as to how to improve the strategy.
  • Risk of Ruin: This shows my chances of blowing out an account with a strategy. I want the risk of a huge loss to be fairly low. Other traders can tolerate a more risky strategy.
  • In and Out of Sample Data: It helps to test a strategy with only part of the historical data, then test the optimized strategy with the rest of the data. If the strategy works well with both data sets, then the strategy is more robust and probably more reliable.
  • Time of Day or Day of the Week Analysis: I look at how profitable certain days are, or how profitable certain hours of the day are, if I'm testing a day trading strategy. This will show me if I might want to stop trading certain days of the week or hours of the day.

The reality of backtesting is that most trading strategies won't be profitable enough to trade with real money. 

But by reviewing the metrics above, I can potentially spot ways to turn a failed strategy into a profitable one. 

I can also potentially make a profitable strategy even more profitable.

Final Thoughts on How to Automate Backtesting

Automated backtesting can take your backtesting process to the next level by allowing you to test a ton of ideas in a very short amount of time.

In addition, you can leverage semi-automated backtesting to test specific aspects of a trading strategy, if the entire strategy cannot be automated.

The technology nowadays is quite good, so I feel that all traders should at least do some automated backtesting because it's so easy and fast.

So if automated backtesting appeals to you, take the time to learn your preferred platform.

It's one of the greatest skills that you can have as a trader.

 

The post How to Automate Backtesting of a Trading Strategy appeared first on Trading Heroes.

]]>
5 Best FX Replay Alternatives (Free and Paid) https://www.tradingheroes.com/fx-replay-alternatives/ Fri, 08 Mar 2024 23:16:59 +0000 https://www.tradingheroes.com/?p=1024275 If FX Replay isn't quite your thing, then these alternatives might be what you're looking for. Both free and paid options are provided.

The post 5 Best FX Replay Alternatives (Free and Paid) appeared first on Trading Heroes.

]]>

If you're not sure about paying for FX Replay or you're already a user and are looking for something different, then this short list will show you the best alternatives that may suit your needs better.

I've been using and reviewing trading software since 2007 and my goal is to give you the best FX Replay alternatives based on my experience, and help prevent you from wasting your money on inferior products. 

I'll provide both free and paid options.

Alright, let's get into it…

The Bottom Line

If you just want a summary of the details below, here are my picks for the best free and paid alternatives.

When you buy something through one of the links on our site, we may earn an affiliate commission.

Best Free

MetaTrader 4 and 5

I've used MetaTrader since 2007 and it's the best free option for Forex traders who don't want to pay for software. Here's how it compares to FX Replay.

  • Totally free software
  • Free historical data
  • Manual backtesting is slow because you have to use a spreadsheet
  • Easy to use interface
  • Works best on Windows, but can be used on Mac and Linux via VM

Best Paid

NakedMarkets

NakedMarkets was launched in 2021 and has become one of the best backtesting software solutions for Forex traders. This is how it stacks up.

  • One-time cost, no subscription fee
  • Updated historical data included, no subscription fee
  • Fastest backtesting solution, with drag-and-drop, no-code Rules, for partial or fully automated backtesting
  • Superior analytics tools
  • Works best on Windows, but can be used on Mac and Linux via VM

Click the button above to get a special discount and bonuses.

If you want more details, here's what you need to know about each alternative.

Paid FX Replay Alternatives

There are many paid backtesting solutions for Forex traders.

I've filtered the list down to these 3 finalists.

Before I get started, you might be wondering why TradingView isn't on this list.

Since FX Replay adds features on top of the TradingView chart interface, I won't include TradingView on this list. FX Replay provides a lot more manual backtesting benefits compared to TradingView, so there's no need to list TradingView.

NakedMarkets (Best Paid FX Replay Alternative)

NakedMarkets is my favorite manual and automated backtesting software.

It's a much better choice than FX Replay.

The primary benefits are a one-time fee, superior analytics and the ability to build automated backtests without any coding knowledge.

You can read my complete review of NakedMarkets here.

Backtesting software example

Benefits Comparison

Downsides Comparison

  • Not browser based
  • Windows based or Mac/Linux via VM

Learn more about NakedMarkets here.

Forex Tester

Forex Tester 5

Forex Tester is not quite as good as NakedMarkets, but it's still a very solid choice.

I've used it for a long time and only switched to NakedMarkets recently.

In terms of how it compares to FX Replay, here's what you need to know.

Benefits Comparison

  • One-time software cost
  • Relatively inexpensive
  • Ability to backtest MetaTrader EAs
  • Easy to use interface

Downsides Comparison

  • Historical data subscription is paid
  • Not browser based
  • Windows based or Mac/Linux via VM

Soft4FX

Soft4FX screen

I'm not a fan of Soft4FX, but it does fill a legitimate niche on this list.

I have purchased and used it in the past.

This is a plugin for MT4 and MT5 that will turn these platforms into manual backtesting software platforms.

Here's how it compares.

Benefits Comparison

  • Low, one-time cost
  • You get free data from your MetaTrader feed

Downsides Comparison

  • A little confusing to install and use
  • No browser option, might not work with a VM
  • FX Replay has slightly better reporting

Free FX Replay Alternatives

It's actually a close call in the free department.

These 2 platforms both have their benefits and downsides, but after some careful consideration, here's the one I would use if I was going to go the free route.

MetaTrader 4 or 5 (Best Free FX Replay Alternative)

These platforms are very similar, so I'll include them together.

MT4 has more custom indicators and EA available, but MT5 is a newer platform and can be used to trade more markets.

Pick the one that you like better.

For manual backtesting purposes, they are equal.

Benefits Comparison

  • Free data software
  • Free historical data
  • Many custom indicators and EAs available online

Downsides Comparison

  • Much slower backtesting than FX Replay because you need to use a spreadsheet
  • No built-in stat tracking and analysis
  • Not quite as easy to use
  • Not browser based, Windows is best

Traders Gym in ThinkTrader

Traders Gym is a free backtesting software that I've featured a couple of times on my YouTube channel.

It's a decent free solution because it has more built-in backtesting features than MetaTrader.

But it does have some limitations that makes MetaTrader a better choice.

You can learn how to use it in this tutorial.

Here's how it compares to FX Replay.

Benefits Comparison

  • Free software
  • Free data

Downsides Comparison

  • Pauses often when it loses internet connection
  • Not as many markets available
  • Interface is not as intuitive as FX Replay
  • A little clunky to use
  • Not browser based

FX Replay Review

FX Replay Features

If you haven't checked out FX Replay yet, here's my summary review of the software and what I think of it.

Full disclosure, I've only tried the free version, but I have also researched it extensively.

I've been doing this long enough that I know what to look for.

Based on my analysis and previous experience with backtesting software, I didn't see any reason to switch from what I currently use.

Benefits

  • Available on any computer via a browser. No clunky software to install.
  • They use TradingView charts, which are the best browser-based trading charts on the planet.
  • The platform provides additional backtesting upgrades on top of the benefits of TradingView charts.
  • Custom indicators are available, some of which are not available on other platforms.
  • Wide range of markets available.

Downsides

  • It is a subscription service, so if you ever decide to switch platforms, you'll lose your backtesting data.
  • Limited analysis metrics.
  • No automation tools.
  • The interface is a little too simple, not enough features.

Final Thoughts

So those are the best options if you're looking for backtesting software that's an alternative to FX Replay.

Based on my extensive research of the product, it doesn't have the same benefits of the paid alternatives on this list.

However, I'm sure that they will be adding new features into the future, so I look forward to seeing what they come up with.

Keep in mind that technology can change quickly, so my analysis is based on the information available at the time this was written.

 

The post 5 Best FX Replay Alternatives (Free and Paid) appeared first on Trading Heroes.

]]>