Trading The Equity Curve & Beyond

Some trading systems have prolonged periods of winning or losing trades. Long winning streaks followed by a prolonged period of drawdown.  Wouldn't it be nice if you could minimize those long drawdown periods?

Here is one tip that might help you do that. Try applying a simple moving average to your trading system's equity curve. Then, use that as an indicator on when to stop and restart trading your system. This technique might change your trading system's performance for the better. 

How to do this? Well, the moving average applied to your trading system's equity curve creates a smoothed version of your trading system's equity curve. You can now use this smoothed equity curve as a signal on when to stop or restart trading. For example, when the equity curve falls below the smoothed equity curve you can stop trading your system.  Why would you do this? Because your trading system is under performing, it's losing money. Only after the equity curve starts to climb again should you start taking your trades once again. This technique is trading the equity curve. You're making trading decisions based upon your equity curve. In essence the performance of your system is an indicator.

Trading the equity curve is like trading a basic moving average crossover system. When the fast moving average (your equity curve) crosses over the slower moving average (your smoothed equity curve) you go long (trade your system live). When the fast moving average crosses under the slower moving average you close your long trade (stop trading your live system).

In the image above the blue line is the equity curve of an automated trading system. The pink line is a 30-trade average of the equity curve. When the equity curve dips below the pink line, such as around trade number 60, you would stop trading the system. Once the equity curve rises above the pink line, around trade number 80, you would start trading. 

It's a great idea and with some systems this technique can work wonders. In essence, we are using the equity curve as a signal or filter for our trading system. In the most simple case, it's a switch telling us when to stop trading it and when to resume trading. But you could also use this signal to reduce your risk instead of turning off the system.

How To Trade The Equity Curve in EasyLanguage

First you need to track all trades to generate the complete equity curve and moving average. This is done even if your live system has stopped trading. In other words, you will need to record the theoretical trades it would be taking. This means you will need to have two copies of your system running. One will is dedicated to taking every trade in simulation mode. This simulated system tracks the theoretical equity curve and computes the smoothed equity curve. No real trades would are taken by the simulated system. Its job is to track the two equity curves.

The second system is dedicated to trading live. This live system will have the ability to trade or not trade based upon the results computed by the simulation system. Think of the simulated system as an indicator. It's always running collecting data and crunching the numbers. This information will then be used by the live system to tell it when to trade and when not to trade.

One method to do this would involve passing data between two charts in TradeStation. Both charts are trading the identical trading system. One trades live while the other trades only in simulation mode. The chart running in simulation mode acts as your indicator. This indicator chart then passes a simple variable to the live chart. The live chart then acts on the live market.

This type of setup produces a dynamic trading system that adjusts its trading behavior based upon the system's performance. It's a simple concept, but it's complex to build in TradeStation. Some solutions that I've seen are also not very flexible. Overall solutions have proven to require complex programming skills and tedious setup to get this to work.

In short, building custom Easylanguage code to trade the equity curve has been very difficult to do. In fact, it has been well outside the ability of most programmers. But, not anymore.

Equity Curve Feedback Toolkit

There is a TradeStation product that can do all the heavy lifting for us! It is, the Equity Curve Feedback Toolkit. This kit allows me to use simple EasyLanguage functions within my code to trade the equity curve. With a little work you can have it up and running.  Let me show you.

I took an example trading system that appeared on System Trader Success called, A Simple S&P System. I then added the Equity Curve Feedback function to my code. Next, I made a couple minor adjustments to my code. Once done, the Equity Curve Feedback function now returns the simulated system's equity curve.

No need to use DLLs or other complicated setups!  With this information you can make a determination if the equity curve is above or below the smoothed equity curve. In other words, you can now turn-off or turn-on your live system based upon the equity curve!

First lets look at the results of Simple S&P System without the equity curve feedback. 

Simple S&P System With No EQ Feedback

You can see by looking at the equity curve the strategy got off to a bad start. See trades 20-40. Then the strategy had a nice run and a huge drawdown around trade 200.

The graph below is the underwater equity on a weekly basis. You can see at the start of trading and at the most recent trades, about a 12% drawdown.

Finally, here is the performance report of the S&P Simple System.

Adding Equity Curve Feedback

There are some adjustments to the original code required. For example, adding number variables and arrays. But at the heart of the issue is computing the equity curve of a simulated version of our strategy. That's difficult to do in EasyLanguage! But not any more.

Below is the line of code which does all the magic! That one line is what computes the simulated trades of our system. 

The next line of code is what enables or disables our live trading system. This function calculates the simulated equity curve of all trades. It then compares this value to the moving average of all simulated trades. It will then return true if the simulated equity curve is above the moving average. Else it will return false. 

I went ahead and added a 30 period moving average to the equity curve. Below are the results.

Watch A Video Demo of This!

Watch a  25-minute demo on how to add equity curve feedback to a trading system. 


It's interesting to note the net profit is about the same. However, it generated this profit with fewer trades. That means many of the losing trades were eliminated. In fact, the average trade increased by about $50. Adding equity curve feedback reduced the drawdown by about half! Looking at the equity curve you can see the deep drawdown at the far-right side has been improved. Also, looking at the first few trades the equity curve looks much better.

You don't have to stop trading when the equity curve falls below its moving average. You could  adjust your risk. That is, if your equity curve begins to fall you can reduce the number of shares or contracts you trade. Or, when the equity curve is climbing, you need to increase your risk by buying more shares or contracts. You could also start or stop trading based upon drawdown or if the percentage of winners falls below a threshold. These are all possible with this kit.

Does It Always Help?

The short answer is, no. Trading the equity curve works well on some trading systems. Those systems tend to have prolonged periods of drawdown. Yet, other systems don't benefit from equity curve feedback. This is because the drawdowns are rather shallow and you end up hurting your equity more than anything. But like most things in the world of trading, you'll have to perform some testing. Test different moving averages and test between halting all trading or reducing contract/share size. Remember, some systems do not benefit from this technique at all.

Going Beyond With Multi-Agent Strategies

The Equity Curve Feedback Toolkit can also be use to create even more dynamic systems.​

For example, you can simulate many different variations of a single trading strategy. Maybe each of the simulated strategies has different input parameters. Instead of relying on a single set of input parameters giving a buy signal, you require two or more of the simulated strategies to give a buy signal. In effect you want confirmation from more than one strategy before taking a signal. This type of model is based upon on a voting scheme. When enough votes are counted - a trade is taken.

In another example you have multiple competing strategies. These strategies can simply be the same strategy with different inputs or they can be completely different types of strategies. A mean reverting strategy and a trend following strategy - for example. Based upon equity curve feedback, the strategy trade the best performing strategy in real time.

These examples are types of multi-agent strategies that can help make more dynamic and/or robust strategies. Such power was not widely available to the retail trader, but now it is.

Build Dynamic Strategies in EasyLanguage!

Let me show you how to build better trading modules in EasyLanguage that adapt in real-time!

About the Author Jeff Swanson

Jeff is the founder of EasyLanguage Mastery - a website and mission to empowering the EasyLanguage trader with the proper knowledge and tools to become a profitable trader. Join our EasyLanguage FaceBook group to interact with other EasyLanguage traders! Click the FaceBook icon to join.

follow me on:
  • Mark says:

    Jeff, you recommend to “test different moving averages and test between halting all trading or reducing contract/share size.”

    Is this not curve-fitting? If it is then is that particular moving average probably going to help or hurt me going forward?

    • Jeff Swanson says:

      IT could be. Anytime you pick a parameter it could be curve fitting or it could just be optimizing. What I often recommend when testing a range of values, a look-back period for a moving average for example, is to test the robustness of the parameter. That is, I would expect to see many different values that produce favorable results. However, if simply changing the look-back period a small amount drastically changes the results, I would be worried about curve fitting. If or when I find a region which appears stable, I will then take the mean or median value.

  • Ryan says:

    Jeff, have you taken a look at MSA software? It will allow for monte carlo testing using an equity curve.

    I did not find equity curve trading worked for me as the curve can take you out just as the best trades are setting up. Especially, when you have strategies where 20% of your trades make up 80% of your profits.


    • Jeff Swanson says:

      I have a copy of the MSA software. I really like it. That’s a good observation about where “traditional” rules for trading the equity curve may not work. In this type of situation you may find it interesting to test increasing your risk when under the equity curve average and reducing risk when it’s above.

  • Jeff Swanson says:

    Actually it’s a completely re-written article written in the last few days! The original article from 2012 did not have a equity curve solution. It only talked about the topic as a theory. There was no solution. So, once I found an EasyLanguage solution I re-wrote the article as the old article become completely obsolete. Thanks for the links to Kevin’s articles. I have yet to read them. It’s true that this technique may not work for all systems. I would never expect a single technique to work on all markets. It does not even need to work on most markets to be valuable. If it only works on less than 5% of strategies developed, it’s worth keeping. Remember, this is just another tool in your toolbox that you may find helpful. I would test this technique like I would test any other technique. How do you test that a trailing stop works or an open range breakout works? What steps are taken to boost the probability of success when incorporating those techniques in your trading? The same steps would apply here. There is nothing different. In all cases, your own system development process should be applied.

  • Claudio says:

    HiJeff, take a look on the following link :


    • Jeff Swanson says:

      Thanks for the link! I’ve heard of this concept before and it’s really an interesting idea. In fact, you could use the Equity Curve Feedback tool to do something similar. For example, you could have a single strategy which trades both a mean reverting strategy and a trend following strategy. Using the functions within the Toolkit you could have it switch between these to types of trades based upon historical performance in real-time.

  • LB says:

    Hi Jeff,
    does it work also with limit and stop orders?

    If i am not wrong it works only with market orders….

  • >