hamster-bot

hamster-bot MRS 2 (simplified version)

hamster-bot Telah dikemas kini   
MRS - Mean Reversion Strategy (Countertrend) (Envelope strategy)

This script does not claim to be unique and does not mislead anyone. Even the unattractive backtest result is attached. The source code is open. The idea has been described many times in various sources. But at the same time, their collection in one place provides unique opportunities.

Published by popular demand and for ease of use. so that users can track the development of the script and can offer their ideas in the comments. Otherwise, you have to communicate in several telegram chats.

Representative of the family of counter-trend strategies. The basis of the strategy is Mean reversion. You can also read about the Envelope strategy.

Mean reversion, or reversion to the mean, is a theory used in finance that suggests that asset price volatility and historical returns eventually will revert to the long-run mean or average level of the entire dataset.

The strategy is very simple. Has very few settings. Good for beginners to get acquainted with algorithmic trading. A simple adjustment will help avoid overfitting. There are many variations of this strategy, but for understanding it is better to start with this implementation.

Principle of operation.
1)
A conventional MA is being built. (fuchsia line). A limit order is placed on this line to close the position.
2)
(green line) A limit order is placed on this line to open a long position
3)
(red line) A limit order is placed on this line to open a short position

Attention!
Please note that a limit order is used. Conclude that the strategy has a limited capacity. And the results obtained on low-liquid instruments will be too high in the tester. On real auctions there will be a different result.

Note for testing the strategy in the spot market:
When testing in the spot market, do not include both long and short at the same time. It is recommended to test only the long mode on the spot. Short mode for more advanced users.


Settings:
Available types of moving averages:
  • SMA
  • EMA
  • TEMA - triple exponential moving average
  • DEMA - Double Exponential Moving Average
  • ZLEMA - Zero lag exponential moving average
  • WMA - weighted moving average
  • Hma - Hull Moving Average
  • Thma - Triple Exponential Hull Moving Average
  • Ehma - Exponential Hull Moving Average
  • H - MA built based on highs for n candles | ta.highest(len)
  • L - MA built based on lows for n candles | ta.lowest(len)
  • DMA - Donchian Moving Average
A Kalman filter can be applied to all MA

The peculiarity of the strategy is a large selection of MA and the possibility of shifting lines. You can set up a reverse trending strategy on the Donchian channel for example.

Use Long - enable/disable opening a Long position
Use Short - enable/disable opening a Short position

Lot Long, % - % allocated from the deposit for opening a Long position. In the spot market, do not use % greater than 100%
Lot Short, % - allocated % of the deposit for opening a Short position

Start date - the beginning of the testing period
End date - the end of the testing period (Example: only August 2020 can be tested)

Mul - multiplier. Used to offset lines. Example:
Mul = 0.99 is shift -1%
Mul = 1.01 is shift +1%

Non-strict recommendations:
1) Test the SPOT market on crypto exchanges. (The countertrend strategy has liquidation risk on futures)
2) Symbols altcoin/bitcoin or altcoin/altcoin. Example: ETH/BTC or DOGE/ETH
3) Timeframe is usually 1 hour

If the script passes moderation, I will supplement it by adding separate settings for closing long and short positions according to their MA
Nota Keluaran:
new option "distance_filter" value in %. If you set it to 0, it means the filter is turned off and not used. The filter disables trading and removes orders if the distance between the opening order and the closing one is less than a specified one

Skrip sumber terbuka

Dalam semangat TradingView yang sebenar, penulis skrip ini telah menerbitkannya dengan menggunakan sumber terbuka supaya pedagang-pedagang dapat memahami dan mengesahkannya. Sorakan kepada penulis! Anda dapat menggunakannya secara percuma tetapi penggunaan semula kod ini dalam penerbitan adalah dikawalselia oleh Peraturan Dalaman. Anda boleh menyukainya untuk menggunakannya pada carta.

Penafian

Maklumat dan penerbitan adalah tidak dimaksudkan untuk menjadi, dan tidak membentuk, nasihat untuk kewangan, pelaburan, perdagangan dan jenis-jenis lain atau cadangan yang dibekalkan atau disahkan oleh TradingView. Baca dengan lebih lanjut di Terma Penggunaan.

Ingin menggunakan skrip ini pada carta?