
A New Era for Retail Traders Begins
Until now, advanced stock trading strategies like automated stock picking were the domain of hedge funds and institutional players. But that’s about to change — for good. We’re introducing AlgoCloud, …
Přejít k obsahu | Přejít k hlavnímu menu | Přejít k vyhledávání
mean reversion
In this simple tutorial we present you a simple approach to setup a builder template that allows you to generate mean-reversion strategies easily. StrategyQuantX can explore millions of possible combinations of a mean-reversion system that can be easily found using its excelent templating system.
The concept is really simple. Imagine the market price does not move too much for some time and either trends slowly or is choppy and then suddenly a quick sell-off occurs. In such situation traders tend to perceive this situation as an opportunity to buy with a discount and ‘fade’ this market action expecting the market price to return back to its average (mean).
This approach is commonly used across all markets but surprisingly works well with stocks and stock index futures naturally. In our example we try to test the idea using US index futures data for an e-mini contract but as mentioned the concept can be used in any market.
An example It can be clearly seen on the following picture. The market moved slowly higher and then suddenly went sharply down. Once we see the movement we could assume this ‘extreme’ to be temporary and try to buy into the price weakness expecting the market price to go back up.
To understand following information we assume you are already familiar with ‘SQ templates and randomization’. If not please skip reading this article for a moment and check our article on Strategy templates.
We could move the idea little further and for a situation where market drops we also assume the drop could continue a little lower before it bounces back to the average thus giving us an additional price discount for the long entry. This is a great opportunity to test a buy limit order how it can perform in this setup and whether it can provide some profit opportunity. So let’s define some basic rules and entry conditions.
It is quite easy to setup a template for this. To keep everything as simple as possible we build the strategy for the long side only while we want StrategyQuantX to build conditions using all available (and enabled) building blocks. We do not want to limit the builder here since we do not know yet what conditions for placing limit order we are going to use. This can be easily achieved using a template with entry conditions as follows:
Note the green-colored items that represent blocks that will be randomly generated later by the builder. We want the builder to optimize it for us
That’s it for the entry signal. Now let’s have a look onto the long entry order tab how to setup the buy limit order correctly using the randomization.
Notice the highlighted part where we set the limit price for the buy limit order. You can see we subtract ATR value again multiplied by a fix value from the last bar close. The fix value will be generated later randomly by SQX in the range from 0.5 to 2 using step = 0.1 (0.5, 0.6, 0.7, …, 1.9, 2). We also want to have the order expiration and stop-loss always enabled in the template so we enable this option as well.
Now the template is basically complete and we can setup a simple build configuration to test how well this can perform.
To test the idea we will be using the data of E-mini S&P 500 index futures contract. You can easily switch to the micro version of this contract (symbol name ET in StrategyQuant Data Manager) with the point value 10 times smaller compared to the mini version.
We use the simplest build config possible since we want StrategyQuantX to generate just a quick prime sample of strategies to see whether this trading approach can provide profitable systems generally. Let’s setup only the essentials:
We also want to see the actual trades that a strategy creates on a price chart so we enable the ‘Store chart data’ option
And finally we want some basic performance metrics set so only profitable strategies are stored into the databank.
When the random generation mode is used you should get first strategies almost immediately after you start the build. Let’s check the best strategy in the first sample whether all works as expected.
We can also see the pseudo code shows a correct strategy logic according to the template setting we used.
And we can check individual trades executions on a chart directly in StrategyQuantX.
Using this basic template you can explore huge amount of possible strategies across forex, stocks and commodities and across all possible timeframes. We do not recommend to test using small timeframes. While the templates provides good results on intraday charts you can also test using daily or weekly timeframes and apply the concept to a broader portfolio of markets.
Until now, advanced stock trading strategies like automated stock picking were the domain of hedge funds and institutional players. But that’s about to change — for good. We’re introducing AlgoCloud, …
Over the past few months, we have added several technical indicators to our coding base. When selecting these indicators, we focused on ensuring that they help users better identify market regimes.
Ever wondered how one idea could revolutionize the way traders build algorithmic strategies? In our brand-new exclusive video interview, we sit down with Mark Fric, the founder and CEO of …
HI Tomas, thanks for the blog, i am following your instructions 1 by 1, and have few issues.
I completed the template and put builder to work, after 1 million of strategy, there is 0 acepted because no trades filter.
I went back to algo wizard, notice that you have got random(multisignalD,0.5:2:0.1), i can only select randomvalue.
Can you point out what i done wrong or where to look up?
You can get the Random(multisignalD,0.5:2:0.1) by setting the element to Number, then for the value of that Number element, use “Generate Random” from the dropdown menu.
awesome !!!! thank you Tomas !!!
Hi, can you explain to me why you are using the previous bar High[1] – Low[1] and RSI[1] as opposed to using the current bar? Trying to understand — in TradeStation when I create limit orders I usually use the current bar [0[ close for my indicators, and then I am trading the next bar on either a limit order or market order at open. Can you explain? I get the feeling I am misunderstanding. Thanks. –Tom C
Hello,
for TS / MC engine you can use [0] bars