# MultiCharts Backtesting Tutorial

**MultiCharts backtesting** is very simple and fast.

**In this tutorial**, we will show you how to perform a MultiCharts BackTest of a simple idea from scratch.

We will show you what your **way of thinking** should be while developing an idea.

It doesn’t matter if your trading system is complex or straightforward; t**he steps are always the same**.

MultiCharts algorithmic trading should not be thought of only for automatic trading.

You can use MultiCharts Backtesting to **perform discretionary strategy backtests**.

Backtesting a discretionary strategy can be complicated, but at least the basic idea must stand up; otherwise, it is useless to waste time.

Many traders underestimate the importance of the MultiCharts Backtest for understanding the market.

Instead, it is possible to use MultiCharts BackTesting to **discover bias** or recurring patterns.

## MultiCharts BackTest First Step

Let’s start with an idea as simple as it is effective over time.

How many times have you heard that the **US stock market responds well to reversal logic**? Well, let’s see if it’s true.

A reversal trading system buys when the market is going down and sells when the market is going up.

Meanwhile, let’s try to verify this hypothesis. Let’s create a system that **buys on the lows of the previous week and sells on the highs of the last week**. This is our simple **EasyLanguage** trading system code:

**If Close > HighW(1) then SellShort Next Bar at Open;**

**If Close < LowW(1) then Buy Next Bar at Open;**

**If barssinceentry > 5 then Begin****if marketposition = 1 then Sell Next Bar at Open;****if marketposition = -1 then BuytoCover Next Bar at Open;****End;**

As you can see in the picture, the strategy, however simple it is winning, and therefore, it can be said that this tool responds well to reversal logic.

You can use this trading system every time you start analyzing a new financial instrument.

Knowing if it fits best in a breakout or reversal trading system is the first step.

At this point, we can obtain a confirmation by doing a **MultiCharts BackTest** of the opposite trading system: **trend follower strategy**.

In this case the Automated Trading System will go to **buy after the breaking of a weekly maximum and to sell after the breaking of a minimum**.

You bet on the continuation of the movement.

**If Close > HighW(1) then Buy Next Bar at Open;**

**If Close < LowW(1) then SellShort Next Bar at Open;**

**If barssinceentry > 5 then Begin****if marketposition = 1 then Sell Next Bar at Open;****if marketposition = -1 then BuytoCover Next Bar at Open;****End;**

## MultiCharts BackTesting Reversal Strategy

Well, we now know that the ETF that reproduces the American stock index responds to reversal logic.

What could be the best way to trade an instrument in a reversal way?

Indeed, the most straightforward and most immediate is the **RSI relative strength index indicator**.

This important indicator indicates areas of oversold and overbought were to open a position contrary to movement.

We create a very simple **EasyLanguage trading system** to start trading with the RSI:

**Inputs:****Length_RSI(14),****OverBougth(70),****OverSold(30);**

**Vars:****Value_RSI(0);**

**Value_RSI = RSI( Close, Length_RSI );**

**If Value_RSI < OverSold then Buy next bar at Open;**

**If Value_RSI > OverBougth then Sell Next bar at Open;**

With a **1.86 profit factor**, the idea may be correct, but the indicator used in its standard version with 14 periods opens **only 15 trades in 20 years**.

**We need at least 100-200 trades** to have statistical value.

We can start to try another setting for the RSI Indicator.

In this MultiCharts backtesting tutorial we’ll use the **MultiCharts backtest optimization.**

## MultiCharts Optimization Trading System

To perform a MultiCharts optimization, you have to select the strategy or signal.

Click on Optimization and select regular optimization.

We’ll talk about the **WalkForward Optimization** in other article.

Now you only have to set the optimizable inputs.

We choose to try a large number of **RSI** value from 1 to 30 with 1 step.

We backtest the overbougth and oversold value with 5 step value.

From the **3d chart**, you can meanwhile see that the system works well with settings between 15 and 25 and overbought levels between 70 and 80 and the oversold level between 25 and 20.

But this doesn’t tell us anything about the number of trades we have said we want to exceed 100-200.

**Using Excel**, it is possible to transfer all data via a **CSV file**.

Using the excel filters in this case, we can eliminate all the settings that produce less than 100 trades.

Then we go to eliminate all the settings that make us have a profit factor below 1.5.

We will notice that we have isolated a series of settings of an RSI between 2 and 4.

May of the best results are achieved with an **RSI between 2 and 4.**

We perform another optimization with low RSI settings:

BackTest Optimization Values:

RSI Length: from 2 to 4 step 1

OverBougth: from 80 to 100 step 2

Oversold: from 0 to 20 step 2

Using Excel filters we eliminate all the settings that produce less than 100 trades and a profit factor below 1.5.

We find an amazing result with 2 RSI period and an oversold and overbougth of 90 and 10.

There is already a great proved strategy that uses 2 period RSI: Larry Connors RSI Strategy.

Let’s try to set our RSI to 2 periods and to foresee an entry in position after an oversold at 10 and an exit with overbought at 90.

As you can see, the trading system operates only long and suffers in times of market collapse.

It is enough to see what happens in the crises of 2000 and 2007.

We have to insert a small filter but without compromising the number of operations that must continue to be high.

To filter the signals, we can use an old trick.

Two moving averages, one fast and one slow to identify the trend.

We will have to perform a backtest to understand which settings to use in order not to decrease the number of operations too much.

**Inputs:****Length_RSI(14),****OverBougth(70),****OverSold(30),****Average_Fast(10),****Average_Slow(50);**

**Vars:****Value_RSI(0),****DownTrend(False);**

**Value_RSI = RSI( Close, Length_RSI );**

**If Average(Close, Average_Fast) > Average(Close, Average_Slow) then****DownTrend = False;**

**If Average(Close, Average_Fast) < Average(Close, Average_Slow) then****DownTrend = True;**

**If Value_RSI < OverSold and DownTrend = False then Buy next bar at Open;**

**If Value_RSI > OverBougth then Sell Next bar at Open;**

With 30 and 60 moving averages we can stop operations during the downtrend phases without reducing operations too much.

So, in summary, we found a 10 period setting of the RSI with an OverBougth at 90 and an OverSold at 10.

We applied a trend filter with two 30- and 60-period moving averages.

This system produces 111 trades with a profit factor of 2.51, a profitable percentage of 79%.

Finally, we can try an output in time after x bars and see if the system improves.

Change the last line of the EasyLanguage code with this:

**If Value_RSI > OverBougth or barssinceentry > Time_Exit then Sell Next bar at Open;**

Remember to add Time_Exit in the input.

**Inputs:****…….****…….****Time_Exit(5);**

**Do you want to learn EasyLanguage & PowerLanguage for TradeStation and MultiCharts? Start here:**

Learn more about EasyLanguage Number to String:

**ATTENTION!! THIS STRATEGY IS FOR EDUCATIONAL PURPOSES ONLY AND SHOULD NOT BE CONSTRUED AS INVESTMENT ADVICE.**

**DON’T USE WITH REAL MONEY !! READ THE **DISCLAIMER