MRS
MRS - Mean Reversion Strategy. This is a counter-trend strategy that works on the assumption that price will return to its average value after deviating from it. The opening order is placed at an offset from the average price. The closing order is placed at the average price with no offset. On a sharp price deviation, a position opens and closes when the price returns to the average value.
Trades under the strategy are generated at moments when the price moves away from the average by a certain percentage. ⚠️ But if the price keeps moving in the same direction without a pullback, the position will be a loss. Price falls — the strategy buys (going against the trend). Price rises — it sells (also against the trend). But the close will happen sooner or later at the average price, in any case.
As a rule, positions under this strategy aren't held for long. And in a calm market you can stay out of a position for a long time.
Working order type: Limit. Placed in advance and moved as the average price changes.
In the simplest implementation, the chart has three MA (moving average) lines.
● The base Fuchsia-colored MA shows the price of the closing limit order. No offset
● The Green Long MA - the price of the limit BUY order that opens the LONG position. It's the base MA simply offset down by a %.
● The Red Short MA - the price of the limit SELL order that opens the SHORT position. It's the base MA simply offset up by a %.
How it works: If both long and short are enabled, 2 orders are placed. If only long or short is enabled, 1 order. While waiting for a position, the orders move along their lines with each new candle. When the price reaches the price of our opening order, a position opens and a closing order is placed at the base MA. The closing order also moves along its MA until it's filled. Then the cycle repeats.
Backtest
Test in the built-in backtester
A Pine Script for testing the strategy on historical data in the TradingView strategy tester. It's a popular strategy and you can find many variations under different names.
-
Links:
- A simple version of the strategy with a minimal set of settings. I recommend starting to get familiar with the strategy using this script.
- A script with a larger set of parameters that can be reproduced in the trading bot.
- A script that lets you place multiple opening orders (increasing the position | averaging in).
You can configure this strategy very flexibly.
-
MA order settings:
- source -
open, high, low, close, hl2, hlc3, ohlc4, hlcc4, oc2 - type - moving average type
SMA, EMA, GMA, HARMONIC, TEMA, DEMA, ZLEMA, WMA, VWMA, RMA, EHMA, THMA, HMA, DMA, ATR, H, L - multiplier - offset. 1 means no offset, 0.99 is -1%, 1.01 is +1%
More on the cap on the number of open positions and placed orders, and other interesting options that can turn this strategy into ColorBox, is described right in the bot's interface.
To be continued...
Backtest the strategy on historical data in the tester and run it in hamster-bot.