Algorithmic trading strategies
Backtesting is the process of testing a trading strategy on historical data. It lets traders evaluate how effective their strategy is and identify its strengths and weaknesses. Backtesting helps you understand how a strategy would perform under various market conditions and lets you optimize its parameters to achieve better results.
All the strategies listed below can be tested on historical data in the TradingView strategy tester.
The bot has its own advanced built-in backtester that lets you correctly test entire trading systems and all the capabilities of the trading bot! Tester description: hamster-bot/bot/backtesting
Trade any idea and any strategy
Any of your strategies can be added to hamster-bot - just submit your request via the form or contact me directly
-
Here's how it works:
- You have an interesting strategy you'd like to trade in an automated way
- Submit a request via the form. Ideally you already have the strategy's Pine Script code
- Wait for a notification that the strategy has been added
- Trade fully automatically on your strategy with the bot
A full implementation of the strategy. This is not alert-based trading. Real-time order and position management.
If you don't have a strategy but you have an idea - Great! Submit a request to have the idea reviewed and turned into a trading strategy, followed by testing the idea on historical data.
More about the service: custom trading strategy and bot development.
Strategy summary table
| Strategy | Type | Entry | Averaging in | Weak spot |
| Strategy Trend Zig Zag, ZZ (ZZ2, ZZ6) | trend, breakout | stop order at the level | no | sideways market, V-reversals |
| ZigZag Double, ZigZag MarketOrder, ZZ-Double-Market-Filter | trend, breakout | stop order / market | no | sideways market, V-reversals |
| Donchian Channel | trend, breakout | stop order at the channel border | no | sideways market |
| RiskTurtle | trend, breakout | stop order at the channel border | no | sideways market |
| Moving Average Crossover | trend | market on MA crossover | optional | sideways market |
| Price vs MA | trend | market when price crosses the MA | optional | sideways market |
| MACD Trend | trend | market on MACD crossover | optional | sideways market |
| Squeeze | trend, breakout | market on candle close | no | false breakouts |
| RSI Pullback | pullback in the trend | market on candle close | no | trend change |
| DoubleDragon | trend, coin pair | market | no | sideways ratio |
| MRS | counter-trend | limit on the MA line | yes (several MAs) | strong trend without pullbacks |
| MRS2, MRS2 FAST | counter-trend | limit on the MA line | no | strong trend without pullbacks |
| MRS3 | counter-trend | limit on the MA line | yes (several MAs) | strong trend without pullbacks |
| HiDeep | counter-trend | market on candle close | yes | prolonged decline |
| RedFlag | counter-trend, long only | market inside the candle | yes | prolonged decline |
| Grid | grid, sideways market | limit orders on grid levels | yes (grid) | strong trend |
Trend strategies:
ZigZag, ZZ, ZZ-2, ZZ-6
The main idea of the strategy is to catch a strong trend move as early as possible and hold the position for the duration of the trend. A trade is opened when the price breaks levels built in advance from past price highs/lows.
It is based on logic similar to the ZigZag indicator:
● When the market starts to turn up, a local low is recorded
● When it turns down, a local high is recorded
These points become reference points. They form the levels the market has to break to confirm the move.
Reversible (flip long ↔ short)
The position is always open and flips from short to long and back. (Unless strategy modifiers are used - they are described below in the «Parameters and modifiers» block)
⚠️ The strategy produces losing trades when the market moves sideways and during V-shaped reversals.
Order type: Stop Market order (on some exchanges it may also be called a Conditional or Trigger order)
● Green marks where the conditional buy order is placed: a breakout of the last significant high.
● Red marks the sell order: the price breaks the last low.
After the strategy starts, if there is no position and the price is between the levels, 1 order to open a long position and 1 order to open a short are placed. If the price is not between the levels or there is an open position, 1 order is placed.
If a position is open, the strategy keeps only 1 order. By default its size = position size * 2, so that it flips the position (closes it and opens a new one of the same size).
Strategy Trend Zig Zag and ZZ - what is the difference
Strategy Trend Zig Zag (zigzag, selected by default when a bot is created) - a simple version with a minimum of settings, the counterpart of the «Simple trend strategy» script on TradingView.
Levels are built the same way as in ZZ2, and the position is flipped by stop orders. The modifiers and filters from the «Parameters and modifiers» block are not used in it.
length- reversal search depth (default 5)detection- length of the smoothing EMA (default 3)
ZZ (zz) - the full version: two level types (ZZ2 and ZZ6) and all the modifiers, filters and position size settings described below.
Level types: ZZ2 and ZZ6
ZZ2 (default) - levels are built from the reversal points of the smoothed price. The algorithm is explained in detail in the «For the curious» block.
depth - reversal search depth (default 5)
detection, detection_type, detection_source - length, type (EMA by default) and price source of the smoothing line whose reversals define the points
rsi_len, rsi_value - an additional RSI condition for a reversal point. Not used when rsi_value = 0
ZZ6 - levels are built from two high/low channels: a fast one of length zz6_len and a slow one of length zz6_len_slow (if not set, zz6_len * 3).
A level is fixed when the fast and slow channels coincide (the price made a new extreme) and the fast channel starts to turn.
In ZZ6 the position size depends on risk: the wider the distance between levels (and so the farther the stop), the smaller the lot.
zz6_risklong,zz6_riskshort- risk per trade in %. Lot = base lot * (risk % / distance between levels in %)zz6_risk_one- use the same risk for short as for long (zz6_risklong)zz6_risk_max- upper limit for this lot multiplier
Parameters and modifiers
Operating mode
reverse- reverse (counter-trend) mode. When the upper level is broken the bot opens a short, when the lower level is broken - a long. Orders in this mode are market ordersalways_in_position- if there is no position and the price has already moved beyond a level (for example after closing by stop or take profit), the bot enters immediately with a market order in the direction of the breakoutone_entry_long,one_entry_short- one entry per new level. If the position from a level has already been closed (for example by take profit or stop), the bot does not enter again on the same levelsingle_entry- strengthens the previous option: the ban on re-entry is lifted not by a new level but only after an entry in the opposite direction
Level settings
level_offset_long,level_offset_short- shift the level by a fixed price amountlevel_multiplier_long,level_multiplier_short- shift the level in percent. 1 - no shift, 1.01 - 1% higherangle_long,angle_short- level slope. The level is multiplied by this value on every new candle and gradually moves toward the price. 1 - a horizontal level
Entry filters
When a filter blocks an entry, the bot does not open a new position, but the order to close the current position at the opposite level stays in place.
use_distance_filter,distance_filter- do not enter if the distance between levels is greater than the given % (the stop is too far)use_flat_filter,flat_filter- do not enter if the distance between levels is less than the given % (a sign of a sideways market)use_narrowing- trade only when the levels are narrowing: the last high is lower than the previous one and the last low is higher than the previous oneuse_ma_filter,ma_filter- do not flip if the fast MA has already moved away from the slow MA by more than the given % against the new directionuse_ma_distance_filter,ma_distance_filter- do not enter if the fast and slow MAs are closer to each other than the given % (no momentum)ma_fast_*,ma_slow_*- type, length and source of the fast and slow MA for the two filters abovefilter_only_open- the distance filters apply only to opening a position; flipping from an already open position is allowed- SuperTrend trend filter (
filter.supertrend) and the other position filters from the commonfilterblock - see «Position filters» in the «Position closing and common options» section
Position size
use_auto_risk- auto risk for ZZ2. The lot multiplier changes smoothly fromauto_risk_coeff_starttoauto_risk_coeff_enddepending on the distance between levels: fromauto_risk_procent_starttoauto_risk_procent_end%. A narrow channel means a bigger lot, a wide one a smaller lotcount_pnl_profit,count_pnl_loss- on a flip, add the profit or loss of the current position to the size of the new onesize_control- protection against doubling: if the position accidentally becomes larger than two entries, the excess is closed with a market order
Position closing
use_tp_between_levels,tp_between_levels_value- close the position in profit if the price has returned inside the channel between the levels and the profit is at least the given %stop_by_new_level- stop at a new level. If after entry the price broke a new level in the direction of the position and then came back to it, the position is closedclose_on_wrong_side- close the position if the price has gone beyond the opposite level by more than 1% (for example the stop order did not trigger because of a gap)use_close_on_levels_crossing- close the position if the levels have crossed (the upper one became lower than the lower one)from_level_price- calculate take profit and minimum profit from the level price instead of the actual entry price
Backtest
Test in the built-in backtester
A PineScript script for testing the strategy on historical data in the TradingView strategy tester:
Recommendations:
(not strict, you can break them for research purposes)
Working timeframe: 4h and higher.
For the curious
The level-building algorithm of the ZZ2 strategy. It does not use the standard ZigZag indicator. The code shows how simple it is and that repainting is ruled out. But the levels are built with a delay of a few candles (this does not hurt the strategy at all)
Three sequentially smoothed EMAs are used. This gives strong smoothing and reduces noise.
The variable z records reversal points. If the EMA turns up → a local low (l) is taken. If it turns down → a local high (h). These points (l and h) become the basis for building the levels.
ZigZag Double, ZigZag MarketOrder, ZZ-Double-Market-Filter
ZigZag variants with separate settings for long and short. The buy level is built from one ZigZag (long_length, long_detection),
the sell level from another (short_length, short_detection). For example, you can enter long on more sensitive levels and short on coarser ones.
The bot runs the strategy over history and keeps a "virtual position". If by history a position in this direction is already open (for example, the real position closed by take-profit or stop), no repeated entry in the same direction is made - the bot waits for the next signal.
- ZigZag Double (
zigzag_double) - entry and reversal with stop orders at the levels, as in Strategy Trend Zig Zag - ZigZag MarketOrder (
zigzag_marketorder) - the same levels, but entry with a market order when a candle has crossed the level and the price is beyond it. The reversal is also a market order - ZZ-Double-Market-Filter (
zz-double-market-filter) - ZigZag MarketOrder with a built-in screener: entries are allowed only after a price and volume impulse (see parameters below)
As in the other ZigZag strategies, the position is closed if the levels cross (the upper below the lower) or the price moves beyond the opposite level by more than 1%.
Parameters
long_length,long_detection- reversal search depth and EMA length for the long level (default 5 and 3)short_length,short_detection- the same for the short level (default 5 and 3)
ZZ-Double-Market-Filter only
screener_up_threshold_pct,screener_bars_back- screener signal: the price has risen by the set % from the lowest close of the lastscreener_bars_backcandles (default 5% over 3 candles). 0 - the screener never triggersscreener_use_24h_vol_filter,screener_min_24h_vol_usdt- additionally require a 24h turnover of at least the set amount in USDT (default 1 000 000)screener_use_vol_growth_filter,screener_vol_growth_candles,screener_vol_growth_threshold_pct- the current candle's volume must exceed the lowest volume of N candles by the set % (default 15 candles, 50%)screener_use_low_filter- enter long only if the current candle touched the leveluse_tema_filter,tema_length,tema_src- TEMA trend filter (default 200, close): long only when TEMA is rising, short only when it is falling
When the screener triggers, the "gate opens" for the bot and one trade on ZigZag signals is allowed. After that trade closes, the gate closes until the next screener signal.
Donchian Channel
The classic Donchian channel breakout strategy. The upper channel border is the high of N candles, the lower one is the low of N candles, the center is midway between them.
Entry: a stop buy order at the upper border and a stop sell order at the lower one. Entry orders are placed only after the price has returned to the channel center.
This protects against entering an already stretched move right after the previous trade.
Exit: stop-loss - a stop order at the channel center, take-profit - a limit order a set % beyond the channel border. The stop and take levels move together with the channel.
⚠️ Like any breakout strategy, it loses in a sideways market: the price touches the border and returns to the center.
Order type used: Market Stop order (entry and stop) and Limit (take-profit).
Parameters
channel_len- channel length in candles (default 25)use_tp,tp- enable the take-profit and its offset in % from the channel border (default 10%)- If the price has moved beyond the opposite channel border by more than 1%, the position is closed with a market order (protection against gaps)
Backtest
Test in the built-in backtester
The script code (PineScript) for the TradingView strategy tester "[TV] Donchian Channel" is available in the bot interface on the strategy page.
RiskTurtle (Donchian Channel + risk management)
A development of the "turtles" idea: entry on a breakout of the slow Donchian channel, protective exit at the middle of the fast channel.
The main difference is that the position size is calculated from risk. The distance from the entry point to the middle of the fast channel is the potential loss. The bot sizes the position so that this loss equals the set % of the deposit. A narrow channel means a bigger position, a wide one a smaller position.
Order type used: Market Stop order.
Parameters
slow_channel_len- length of the slow channel whose borders are used for entry orders (default 50)fast_channel_len- length of the fast channel whose middle is used for the protective close (default 25)risk_long,risk_short- risk per trade in %risk_max- maximum lot multiplier, so that the position does not get too big on a very narrow channellevel_offset_long,level_offset_short- shift of the entry levels by a fixed amount in price
Moving Average Crossover, Price vs MA, MACD Trend
Three classic trend strategies based on moving averages. All actions are market orders on a chart signal. The opposite signal closes the position (without reversing), and a new position opens on the next signal.
- Moving Average Crossover (
movingaveragecrossover) - the fast MA crossed the slow one upwards - buy, downwards - sell - Price vs MA (
pricevsma) - the close price crossed the MA upwards - buy, downwards - sell. You can enter not only at the moment of the crossover but on any candle while the price is on the right side of the MA - MACD Trend (
macdtrend) - the MACD line crossed the signal line upwards - buy, downwards - sell. A trend filter can be enabled
⚠️ Like any MA trend strategy, they lose in a sideways market because of frequent false crossovers.
Parameters
Moving Average Crossover
fast_ma_type,fast_ma_source,fast_ma_len- fast MA (default EMA, close, 9)slow_ma_type,slow_ma_source,slow_ma_len- slow MA (default EMA, close, 21)
Price vs MA
ma_type,ma_source,ma_len- MA (default SMA, close, 200)use_cross_entry- enter only at the moment of the crossover (default). If off - enter on any candle when the price is above the MA (long) or below it (short)
MACD Trend
ma_source,fast_len,slow_len,signal_len- price source and EMA lengths for MACD (default close, 12, 26, 9)use_trend_filter- long only in an uptrend, short only in a downtrend. Works together with the enabledfilter.supertrendfilter (see "Position filters")
Common to all three
count_max- maximum number of entries into the position, including the first (default 1 - no adding). Adding happens on a repeated signal in the same direction (in Price vs MA - only withuse_cross_entryoff)entry_gap- minimum step for adding: the next entry only if the price is below the previous entry price *entry_gap(for long; mirrored for short). For example 0.98 - no closer than 2%. 0 - no limit
Squeeze (breakout after a volatility squeeze)
A trend strategy that trades the breakout after a volatility squeeze (squeeze). A squeeze is when the Bollinger Bands
sit entirely inside the Keltner Channel: the market has gone quiet and the range is narrower than usual. After such a lull the
price often makes a strong move in one direction, and the strategy enters at its start.
- The squeeze must last at least
squeeze_min_barsbars in a row - For
release_barsbars after the squeeze ends the strategy waits for a breakout: a closed bar closes above the upper Keltner Channel border for the first time - buy, below the lower border - sell - Entry with a market order on the next tick after the signal bar closes
- Exit: stop, target and trailing stop in ATR (see below), and optionally a closed bar returning past the Keltner Channel
middle line. The common exits from the
optionsblock work too
The bot chart shows the Bollinger Bands (blue) and the Keltner Channel (orange).
ATR stop, target and trailing stop. At entry the bot stores the ATR and computes the levels: stop = entry price ∓ stop_atr × ATR,
target = entry price ± take_atr × ATR. The trailing stop follows the best price since entry at a distance of
trail_atr × ATR and works together with the stop - whichever is closer to the price triggers. Levels are checked on every
tick against the current price and the position is closed with a market order. Levels are saved in the bot state and survive a
restart. If the position was opened manually or by another strategy, the levels are computed from its entry price and the current ATR.
⚠️ False breakouts: after a squeeze the price can leave the channel and come straight back. In a sideways market without follow-through the strategy collects a series of small stops.
Parameters
The squeeze block in the bot settings, basic.strategy: squeeze
bb_len,bb_mult- Bollinger Bands period and width in standard deviations (default 20 and 2)kc_len,kc_mult- Keltner Channel period and width in EMA of true range (default 20 and 1.5)squeeze_min_bars- how many bars in a row the Bollinger Bands must stay inside the Keltner Channel to count as a squeeze (default 6)release_bars- for how many bars after the squeeze ends a breakout still counts as a signal (default 3)atr_len- ATR period for the stop, target and trailing stop (default 14)stop_atr- stop distance from the entry price in ATR (default 2). 0 - no strategy stoptake_atr- target distance from the entry price in ATR (default 0 - no target)trail_atr- trailing stop from the best price in ATR (default 3). 0 - no trailing stopexit_on_basis- close the position when a closed bar returns past the Keltner Channel middle line (off by default)
Entry filters (MA trend, ADX, liquidity, time) are now set in the common filter block and work the same way in most other strategies - see «Position filters» in the «Position closing and common options» section. The old entry_filter block in the strategy settings is moved there automatically on load.
RSI Pullback (entry on a pullback in the trend)
Entry on a pullback in the direction of the trend (rsipullback). The direction is set by a moving average (EMA 200 by
default): long only when the closed bar is above it, short only below. Inside the trend the strategy waits for a pullback shown by
RSI and enters when the pullback ends.
- Long: price above the trend MA and RSI coming back from oversold - crossing
oversoldupwards - Short: price below the trend MA and RSI coming back from overbought - crossing
overboughtdownwards - With
entry_on_crossoff, the strategy enters right away while RSI is in the zone, without waiting for the return - Entry with a market order on a closed-bar signal
- Exit: RSI reached
exit_long_rsi/exit_short_rsi; a closed bar crossed the trend MA against the position (exit_on_trend_break); stop, target and trailing stop in ATR. The common exits from theoptionsblock work too
The bot chart shows the trend MA.
ATR stop, target and trailing stop. At entry the bot stores the ATR and computes the levels: stop = entry price ∓ stop_atr × ATR,
target = entry price ± take_atr × ATR. The trailing stop follows the best price since entry at a distance of
trail_atr × ATR and works together with the stop - whichever is closer to the price triggers. Levels are checked on every
tick against the current price and the position is closed with a market order. Levels are saved in the bot state and survive a
restart. If the position was opened manually or by another strategy, the levels are computed from its entry price and the current ATR.
⚠️ Weak spot - trend change: the pullback the strategy bought may turn out to be the start of a reversal. The ATR stop and the exit on a trend MA break protect against it.
Parameters
The rsi_pullback block in the bot settings, basic.strategy: rsipullback
rsi_len,rsi_source- RSI period and source (default 14, close)oversold- oversold level for long (default 30)overbought- overbought level for short (default 70)entry_on_cross- enter when RSI comes back from the zone (default). When off - enter while RSI is in the zoneexit_long_rsi- close long when RSI rises to this level (default 55). 0 - don't close by RSIexit_short_rsi- close short when RSI falls to this level (default 45). 0 - don't close by RSItrend_ma_type,trend_ma_source,trend_ma_len- trend MA (default EMA, close, 200)exit_on_trend_break- close the position when a closed bar crosses the trend MA against it (on by default)atr_len- ATR period for the stop, target and trailing stop (default 14)stop_atr- stop distance from the entry price in ATR (default 2). 0 - no strategy stoptake_atr- target distance from the entry price in ATR (default 0 - no target)trail_atr- trailing stop from the best price in ATR (default 0 - no trailing stop)
Entry filters (MA trend, ADX, liquidity, time) are now set in the common filter block and work the same way in most other strategies - see «Position filters» in the «Position closing and common options» section. The old entry_filter block in the strategy settings is moved there automatically on load.
DoubleDragon (experimental stage)
This is the same ZigZag strategy, but used a little differently. The whole difference is that we look at the backtest on the chart of the ratio of two coins XXXUSDT/xxxusdt.
Where a Long position opens on the synthetic chart in the strategy tester, on the real market a Long opens on XXXUSDT and a Short on xxxusdt.
Where a Short position opens, on the real market a Short opens on XXXUSDT and a Long on xxxusdt.
Parameters
The strategy runs two bots - one for each coin of the pair. The levels are built on the synthetic price ratio chart and calculated with the settings of the first bot.
index- which coin of the pair this is: 1 - numerator (XXXUSDT), 2 - denominator (xxxusdt)strategy- which levels to trade the synthetic chart on:zigzag(default) ordonchianzigzag- ZigZag settings block:length,detection,detection_source(as in Strategy Trend Zig Zag)donchian- Donchian channel settings block:channel_len,use_tp,tp,detection_source(as in Donchian Channel)reverse- reverse mode: trade directions are swapped
Backtest
Test in the built-in backtester
Script (PineScript) for testing the strategy on historical data in the TradingView strategy tester:
But as the input in the strategy tester we choose a synthetic chart instead of a single trading pair.
The synthetic ratio chart BYBIT:XXXUSDT.P/BYBIT:xxxusdt.P (where XXX is any cryptocurrency priced higher than xxx)
Strategy tester result for 2025, BYBIT:ETHUSDT.P/BYBIT:APTUSDT.P on the 1D timeframe:
Counter-trend strategies:
Mean reversion strategy | MRS | Envelope trading strategy (ShiftMA, MultiMA, Colorbox)
MRS - Mean Reversion Strategy, also known as the Envelope trading strategy. It is a counter-trend strategy based on the assumption that the price returns to its average 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 without an offset. On a sharp price deviation a position opens, and it closes when the price returns to the average.
Trades are generated 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 at a loss. The price falls - the strategy buys (going against the trend). The price rises - it sells (also against the trend). But sooner or later the close happens at the average price anyway.
As a rule, positions in this strategy are held briefly. And in a calm market you can stay without a position for a long time.
Order type used: Limit. Placed in advance and moved as the average price changes.
In the simplest form there are three MA lines (moving averages) on the chart.
● The Fuchsia base MA shows the price of the closing limit order. No offset
● The Green long MA - the price of the limit BUY order that opens a LONG position. It is the base MA shifted down by a %.
● The Red short MA - the price of the limit SELL order that opens a SHORT position. It is the base MA shifted up by a %.
How it works: if both long and short are on, 2 orders are placed. If only long or short is on, 1 order. While waiting for a position, the orders move along their lines on every new candle. When the price reaches 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 is filled. Then the cycle repeats.
The long MA and short MA lines form an envelope around the base average, which is why this approach is called an Envelope trading strategy. More about the envelope indicator: Envelope on Investopedia.
MA line settings (opening and closing orders)
There can be several opening lines for each side (ma_long, ma_short) - this gives a grid of orders with averaging in (MultiMA).
There is one closing line for each side (ma_close_long, ma_close_short) - the whole position is closed with one order.
- id - line sequence number, no repeats
- type - moving average type
SMA, EMA, GMA, HARMONIC, TEMA, DEMA, ZLEMA, WMA, VWMA, RMA, EHMA, THMA, HMA, DMA, ATR, H, L - source - price source
open, high, low, close, hl2, hlc3, ohlc4, hlcc4, oc2 - len - MA length
- multiplier - offset. 1 means no offset, 0.99 means -1%, 1.01 means +1%
- lot_x - lot multiplier: order size = base lot * lot_x. Not used for the closing order
- order_type -
limitormarket. A market order is sent when the price reaches the line - post_only - limit order as maker only
- hidden - hidden limit order (BitMEX only)
Lot setup. In the basic settings set balance_percentage = 100 and risk = 1. Then lot_x = 1 - an order for 100% of the balance, 0.5 - for 50%, 1.5 - for 150%.
Strategy parameters
entry_on_close- for market opening orders: check the entry condition against the last candle's close price instead of the current pricetrade_offset- for market opening orders: take the MA value N candles backreverse_mode- for market opening orders: enter not when the price crosses the line, but when the price is above the line (for a buy) or below it (for a sell), no further than 1% from itrecalculate- recalculate order sizes on every update, even if a position is already openclose_on_signal- starting from the second candle after entry, close the position with a market order as soon as the price touches the closing lineclose_on_wrong_side- if the price has moved beyond the closing line by more than 0.5% and the limit order was not filled, close the position with a market orderemergency_stop- emergency stop: if the opening line ends up on the other side of the closing line (the lines crossed), the bot cancels all orders and closes the positionnotification_trade_report- a Telegram report for each closed trade: average entry price, exit price and the result in %position_priority- position priority for the position limiter (see below)
Position limiter
The limiter is set for an API key with the "open_positions_limiter": 64 parameter in the key file in the settings_account folder. Default 0 - off.
Only MRS bots whose position_priority is not 0 take part in the limiter.
position_priorityfrom 1 to 5. 5 is the lowest priority, such a position closes first- If there are as many open positions as set in the limiter, opening orders are cancelled on pairs without a position - no new positions are opened
- If more positions opened than the limit (for example at the same time), the extra ones are closed: first with priority 5, then 4, 3, 2, 1. With equal priority - a random one
- Positions with priority 0 are not counted and not closed by the limiter
In the interface the limiter is shown like this: [100 | (4/64)] - 100 bots on this API, 4 positions open, limit 64.
The same open_positions_limiter parameter also limits the HiDeep and RedFlag strategies: when there are as many open positions on them as the limit, bots without a position do not open new trades. Priorities are not used for them.
ColorBox - close on the N-th candle
A closing option that turns MRS into ColorBox: the position closes at the close of the N-th candle after entry. You can add a candle color condition, for example close after the 2nd green candle. Set separately for long and short. Details are in the "Position closing and common options" section.
Backtest
Test in the built-in backtester
Script (PineScript) for testing the strategy on historical data in the TradingView strategy tester. The strategy is popular, and you can find many variations under different names.
-
Links:
- A simple version of the strategy with a minimum of settings. I recommend starting with this script.
- A script with a large set of parameters that can be reproduced in the trading bot.
- A script that can place many opening orders (increasing the position | averaging in).
Recommendations:
(not strict, you can break them for research purposes)
● A limit order limits the strategy's capacity. On low-liquidity instruments the tester result will be overstated.
● On spot, test long only. Long and short at the same time is for experienced users.
● On futures a counter-trend strategy carries a liquidation risk.
● Typical timeframe - 1h. Altcoin/bitcoin or altcoin/altcoin pairs.
MRS2, MRS2 FAST
A version of MRS with separate closing lines for long and short and a set of filters that cancel orders at dangerous moments. One opening line per side, no averaging in.
Order type used: Limit. The opening and closing orders move along their own lines.
By default the bot does not trade if the opening line ends up on the other side of the closing line (for example, the buy line is above the long closing line) - such a trade is a loss from the start.
Parameters
ma_long,ma_short,ma_close_long,ma_close_short- opening and closing lines. Configured the same way as lines in MRSuse_settings_from_open_long,use_settings_from_open_short- build the closing line with the type, source and length of the opening MA (the offset is taken from the closing line)distance_filter- minimum distance in % between the opening and closing line (default 0.3). If closer, orders are cancelled (the potential profit is too small)filter_pump_1- post-pump filter. When the price (source) crosses the closing line upwards, the level of that lineoffsetcandles back is remembered. While the buy line is above this level, the bot does not buyfilter_pump_2- sharp rise filter. If over the lastcountcandles the high isvaluetimes bigger than the low and the high came after the low, trading is pausedfilter_close_position- when a filter triggers, not only cancel orders but also close the open positionunconditional_placement- always place orders, without checking the relative position of the linesallow_close_by_market_order- if the whole candle went above the closing line and the limit order was not filled, close the position with a market orderonly_profit- do not move the closing order below the entry price (for long) - close only in profitreplace_open_order- with an open position, the size of the opening order is reduced by the position sizecancel_if_half_filled- if the opening order is partially filled and the remaining part is less than twice the position, it is cancelled
MRS2 FAST (mrs2fast) - the same logic and the same settings (the mrs2 block), but in one pass the bot performs all the needed order actions at once (update the closing order, move the opening order, etc.) instead of one action per pass. Orders keep up with the MA lines faster - useful on lower timeframes and with many bots.
MRS3
A combination of MRS and MRS2: several opening lines on each side (a grid of orders with averaging in, like MultiMA in MRS) and the set of protections from MRS2.
Order type used: Limit. Each opening order moves along its own line, the closing order moves along the closing line.
Parameters
ma_long,ma_short- lists of opening lines. Configured the same way as in MRS (id, type, source, len, multiplier, lot_x, order_type, post_only, hidden)ma_close_long,ma_close_short- one closing line per sidedistance_filter,filter_close_position,unconditional_placement,allow_close_by_market_order,only_profit- as in MRS2replace_open_order- with an open position, the position is spread across the grid levels starting from the one nearest to the price: filled levels are not re-placed, a partially filled level gets the remainder, untouched ones get the full lotuse_id_tracking- track grid orders by ID (no more than one request to the exchange per pass). Useful when the exchange limits request ratesnotification- a Telegram report for each closed trade: entry price, exit price and the result in %
HD, HiDeep
This strategy came out of long thinking about how to improve the mean reversion | MRS | Envelope strategy, and those improvements turned into a separate strategy.
Key fundamental differences from MRS:
● works only with market orders. The price at which the buy/sell will happen is not known in advance, so nothing can be placed ahead of time
● all actions happen at the moment the candle closes. This gives a very simple, robust strategy logic that backtests very well even in primitive strategy testers
● a non-obvious consequence of the point above - much better survival of the strategy during sharp moves within a single candle. Nothing happens inside the candle, even if the candle makes an 80% price move.
● the strategy uses the MRS logic as one of the conditions (a filter) for triggering an order.
● unlimited averaging in.
It is a counter-trend strategy that looks for moments of local oversold conditions and opens buys on pullbacks down, expecting a subsequent bounce.
It combines:
● entry filtering with a moving average (as in the strategy above - Mean reversion | MRS)
● analysis of the price deviation from the average
● a simple oversold model (similar to RSI). The price falls faster than usual.
● exit on signs of price recovery (the mirror-opposite of the buy conditions)
The strategy tries to catch a situation where:
● The price has dropped sharply
● The move looks "overloaded" (too strong compared to normal)
● There are signs of short-term oversold conditions
At such moments it assumes the market has temporarily overshot downwards and may bounce.

An example of a HiDeep strategy variation on the chart above.
Long entry and subsequent averaging in on candles that are:
● below the green trigger MA line shifted down
● marked with a green triangle ▲
The position closes when the High touches the red MA line. (action at the candle close)
The blue line shows the average buy price.
⚠️ In a prolonged decline without a bounce, the position keeps growing through averaging in and the loss grows. Limit the number of averaging entries and the lot size.
How the signal is determined (green/red triangle)
A buy signal (green ▲) appears on a candle that at the same time:
● is red (closed below its open)
● has its body below the body of the previous candle
● has a deviation of the close price from the SMA larger than the average deviation over recent candles (the move is "overloaded")
● has a fast RSI below 10 (strong short-term oversold)
A sell signal (red ▼) is the mirror: a green candle, body above the previous one, a strong upward deviation, fast RSI above 90.
Signals are calculated with two independent sets of settings, and either one triggers. In addition, the close price must be below the MA low line (for a buy) or above MA high (for a sell).
Parameters
MA lines
ma_low_*,ma_high_*- type, length and source of the entry filter lines. ATR can be used instead of an MAma_low_1,ma_high_1- offset of the filter lines. 0.995 - 0.5% lower, 1.011 - 1.1% higherma_high_trigger_*,ma_low_trigger_*- closing trigger lines: long closes when the candle High is abovema_high_trigger, short when the Low is belowma_low_trigger
Signal
up_1,dn_1,mac_1,sma_1,sma_up_1,sma_dn_1- first set: fast RSI length up/down, SMA length for the deviation, deviation averaging length, threshold multipliersup_2...sma_dn_2- second set with the same parameters
Averaging in and closing
count_max_long,count_max_short- maximum number of entries into the position, including the first (default 5)entry_gap- minimum averaging step: the next buy only if the price is below the previous buy price *entry_gap. For example 0.98 - no closer than 2%. 0 - no limitonly_profit,min_profit- close on the trigger line only in profit.min_profit- multiplier to the entry price, e.g. 1.01 - profit of at least 1%allow_reduce- close the position on the opposite signal (for long - on the red ▼)reduce_ma_1- close on the opposite signal only if the price is beyond the opposite MA lineallow_reverse- on the opposite signal, reverse the position instead of just closing it
Modes
use_pdd- inverted mode: buy on an overbought signal above theMA highline, sell on an oversold signal belowMA low. The strategy becomes a momentum strategydisable_trade_on_reverse_trend- with the trend filter enabled (filter.supertrend), do not open trades on the candle where the trend changeduse_auto_size_hedge,auto_size_hedge_ratio- automatic size for hedging. The entry size depends on the total size of trend positions of other bots on this account: the more trend shorts, the bigger the HiDeep buy, and vice versadelay- pause between checks in ms (at least 3000)
The bot starts trading only when enough candles are loaded to calculate the indicators. With the trend filter enabled, at least 500 candles are needed.
Backtest
Test in the built-in backtester
Scripts (PineScript) for testing the strategy on historical data in the TradingView strategy tester. The hamster-bot-HiDeep script contains three different variants of the strategy - pick the one you need with a preset in the settings.
RedFlag
A simple strategy that buys a sharp drop. Works only long.
The bot watches the current candle. If the candle is red and the price has dropped by the set % from the previous candle's price (open, high, low or close, your choice), the bot buys with a market order right away, without waiting for the candle to close. If the drop continues, it averages in.
Order type used: Market (entry) and Limit (take-profit).
⚠️ In a prolonged decline without a bounce, averaging in increases the loss. Limit the number of entries.
Parameters
drop_percent- how many % the price must drop to enter (default 10%)from- which price of the previous candle to measure the drop from:open,high,low,closecount- maximum number of entries, including the firsttimer- minimum pause between entries in minutes. 0 - no pauseeach_tp- each entry gets its own limit take-profit attake_profit_long% from that entry's price. Without this option there is one take-profit for the whole position
Grid (grid strategy)
Grid strategy (grid). The bot places limit buy and sell orders at equal intervals within a set price range.
When the price goes down, the bot buys; when it rises by one grid step, the bot sells what it bought. Each pair of trades "bought at a level → sold at the next level up"
earns one grid step minus fees.
The grid does not need to guess the market direction: it profits from price swings inside the range, so it works best in a sideways market. The grid can run permanently or start in cycles on a signal: for example, when the price deviates from a moving average or moves outside a Bollinger band.
- The range from the lower to the upper bound is split into
grid_countcells: 20 cells - 21 price levels. Buy orders sit below the current price, sell orders above it, and one level next to the price stays empty - A buy is filled - a sell is placed one level higher. A sell is filled - a buy is placed one level lower
- One cell is one fixed size that the bot buys or sells at one level
- The bot derives the grid state from the position size, not from a saved order history. The grid survives a bot restart, partial fills and manual intervention: on the next minute the bot places missing orders and removes extra ones. Orders that are not on grid levels are left untouched
- Where to buy and sell is defined by the bounds, number of cells and step, not by indicators. Candles of the strategy timeframe (
basic.time_frame) are only needed for ATR, Bollinger bands, the start signal, filters andtime_close
Order type used: Limit (maker only by default). Market - initial buy, grid stop and stop-loss.
The bot chart shows the grid levels: buys, sells, the empty level and the bounds. With more than 60 levels only the bounds are shown. While the grid waits for a signal, the chart shows the threshold lines.
⚠️ In a strong trend the grid accumulates a position against the move (a long grid in a decline) or exits the position too early (a long grid in a rally).
Protection against a prolonged trend - stop_out_percent, position filters and the position limit.
How the range is set - range_type
| Value | Grid bounds | When it fits |
fixed | Set manually: lower_price and upper_price | You know the corridor the price moves in |
percent | ± range_percent % from the start price | The universal default |
atr | ± atr_mult × ATR from the start price | The grid width adapts to the current volatility |
bollinger | Between the Bollinger bands (bb_len, bb_mult) at build time | The grid covers the current price swing corridor |
The percent, atr and bollinger bounds are calculated once, when the grid is built. After that the grid stays in place until it is rebuilt by trailing,
a restart after a stop or a new signal cycle. If at build time the price is outside a Bollinger band, the bound on that side moves to the price.
Direction - direction
| Value | Holds | How it works |
long | Long | Buys below the price, sells above. The classic spot grid: accumulates the coin on the way down and sells it on the way up |
short | Short | Mirrored: sells above the price, buys back below. Builds a short as the price rises |
neutral | Long or short | No position at the start price. Builds a long below it and a short above it. Futures only and only without a start signal |
both | Long or short | Only for signal start (start): the signal picks the side of each cycle |
On spot only the long direction is available.
Level spacing - spacing
geometric- equal step in percent. For wide ranges: the cell profit in percent is the same across the gridarithmetic- equal step in price. For narrow ranges
Trailing - trailing
A regular long grid sells everything in a strong rally and stops above the range with no position. With trailing the grid follows the price:
when the price moves one step above the upper bound, the bot rebuilds the grid around the new price. With initial_market the bot buys the grid position again.
A short grid with trailing follows the price down the same way.
Trailing works with range_type percent, atr and bollinger. It does not apply to neutral and does not work in signal cycles: there the price leaving the range means the end of the cycle.
Grid stop - stop_out_percent and restart_after_stop
If the price moves beyond the lower or upper bound by more than stop_out_percent %, the bot cancels all grid orders and closes the position at market.
restart_after_stop: false- the grid stays stopped until you change its settingsrestart_after_stop: true- the bot immediately builds a new grid around the current price. Does not work withrange_type: fixed
In signal cycles restart_after_stop is not needed: after a stop the grid always waits for the next signal.
Signal start - start
By default (start: immediate) the grid starts right away and runs permanently. It can also be started in cycles on a signal, like the entry in the MRS2 strategy.
| Value | Long signal | Short signal |
immediate | The grid is built right away | - |
deviation | Price is start_deviation_percent % below the moving average | Price is the same % above the average |
bollinger | Price is below the lower Bollinger band | Price is above the upper band |
The moving average for deviation is set by start_ma_type, start_ma_len and start_ma_source. The bands for bollinger - by bb_len, bb_mult and bb_ma_type.
How a cycle goes:
- The bot waits for a signal. Example: the price dropped 5% below the average
- A long grid is built from the signal price with the current range settings. With
initial_marketthe bot buys the grid position - The grid trades until it sells all cells. Usually this means the price came back up through the whole range. A cycle also ends on a stop:
stop_out_percent,options.stop_loss_*oroptions.time_close - The bot cancels the orders and waits for the next signal. A new cycle in the same direction starts only after a new crossing: the price must return above the threshold and drop below it again. So after a stop in a deep decline the grid does not restart right away
For a short everything is mirrored. Which sides are allowed is set by direction: long - only long cycles on a downward signal, short - only short cycles on an upward signal,
both - the signal picks the side.
Signal start works with range_type percent, atr and bollinger. While the grid waits for a signal, the bot status shows the thresholds and the chart shows the signal lines.
If the bot starts with an existing position, the grid continues the cycle in that position's direction.
- Combining
start: bollingerandrange_type: bollinger. At the signal the price is at the edge of the grid, so a long grid withinitial_marketimmediately buys almost all cells and then sells them as the price returns to the upper band. If you want the grid to buy more on a further decline, userange_type: percentoratrwith the signal: then the signal price is in the middle of the grid - With
direction: bothshort cycles also open in a rising market. If the rally continues after an upward signal, the short grid fills up completely. Limit this risk withstop_out_percentor choose one side
Size and risk
The size of one cell equals the regular strategy lot from the basic section: for long and neutral - lot_long or balance_percentage_long,
for short - lot_short or balance_percentage_short, for both - by the side of the current cycle.
The bot calculates the size at the grid build price and keeps it until the next rebuild.
Maximum position = cell size × number of cells. For a new strategy the default cell is 10% of the balance, 20 cells, and the balance used for the calculation is capped at 1,000 (max_balance).
Then one cell is about 100 USDT and a fully filled grid is about 2,000 USDT, i.e. 200% of the balance. On futures this needs leverage of at least 2. On spot the lower buys will fail once the money runs out.
If this risk is too high, reduce balance_percentage_long (5% per cell gives about 100% of the balance for the whole grid) or enable the position limit options.size_control.max_balance_percent.
Initial buy - initial_market. If the start price is in the middle of the range, a long grid has empty levels above the price and nothing to sell there.
With initial_market: true the bot buys at market on start as many cells as there are levels above the price. With the default settings that is about 10 cells, ~1,000 USDT, the whole calculated balance, at once.
For short the bot likewise sells the cells below the price, for neutral it closes the existing position.
With initial_market: false the bot buys nothing on start and counts the existing position as filled cells. Without a position a long grid will only buy on dips and will not profit from a rise.
Filters and common settings
- Position filters (the
filterblock) - ADX, SuperTrend, trend MA, trading time and others - only limit entries for the grid. While a filter forbids long, the grid does not place orders that increase the long. Orders that reduce the position keep working, and the grid calmly closes the cells already filled. When the filter allows entries again, the missing orders appear by themselves. Short works the same way. Aneutralgrid with long forbidden does not build a long below the start price but still buys back its short - While entries are forbidden, the grid is not built, does not start a signal cycle and is not moved by trailing if that requires buying the position at market (
initial_market). The reason is shown in the bot status. Example:filter.adxwithmax: 25keeps the grid working only in a calm market - when ADX rises above 25 and a trend starts, no new cells are filled - Position limit -
options.size_control.max_balance_percent. The grid will not fill more cells than fit into this percentage of the balance, including the initial market buy. For example, a grid of 20 cells at 10% of the balance would fill up to 200%, but with a 50% limit it stops at about 5 cells. Far buys are not placed until the grid sells part of the position - Stop-loss (
options.stop_loss_*) is calculated from the average price of the grid position. If the price moves further than the set percentage, the bot closes the position at market, cancels the orders and stops the grid. The stop-loss is executed at market even ifsl_by_orderis on time_closewithbars_countcloses the position N bars after the grid opened it from zero and also stops the grid. Fills of individual levels do not reset this counttime_closeby day of week or month closes the position on the set day, starting fromtime_of_day. Time is taken from the bar open, so on hourly bars 15:30 triggers from the 16:00 bar. A new grid or new cycle starts on the next day- After a stop by stop-loss or
time_closethe grid behaves the same as afterstop_out_percent: withrestart_after_stop: trueit is rebuilt from the current price, in signal cycles it waits for a new signal, otherwise it stays stopped until the settings change - Take-profit from
optionsis not used by the grid: it takes profit at every level itself
Fees: minimum step
Each cell is two trades, a buy and a sell. The cell profit is roughly the grid step minus two fees. If the step is smaller than two fees, every trade loses money, and the more actively the grid trades, the more it loses. Example: ±8% and 20 cells with geometric spacing give a step of about 0.8%; with a 0.02% maker fee, 0.04% goes to fees and a cell earns ~0.76%. A ±2% range with the same 20 cells gives a step of only 0.2%, and fees already eat a fifth of the profit. Bollinger bands on a short timeframe often give a narrow range: check the step in the bot status after the grid is built.
To pay the maker fee, keep post_only: true. An order that would fill immediately at market is rejected by the exchange, and the bot places it again on the next minute.
Parameters
The grid block in the bot settings, basic.strategy: grid
range_type- how the bounds are set:fixed,percent,atr,bollinger(defaultpercent)lower_price,upper_price- lower and upper bound (fixedonly)range_percent- range width in % from the start price in each direction (percentonly, default 8)atr_len- ATR period on the strategy timeframe (atronly, default 14)atr_mult- range width in ATR in each direction (atronly, default 8)bb_len- Bollinger bands period (forrange_type: bollingerandstart: bollinger, default 20)bb_mult- band width in standard deviations (default 2)bb_ma_type- middle line of the bands (defaultSMA)grid_count- number of cells (default 20). More cells - smaller step and profit per trade, more frequent tradesspacing-geometric(step in %) orarithmetic(step in price), defaultgeometricdirection-long,short,neutralorboth(only with a start signal), defaultlonginitial_market- when building, bring the position to the grid position at market (default on)orders_per_side- how many orders closest to the price to keep on each side (default 10); 0 - all levels. Saves margin and the exchange open-order limitpost_only- place orders as maker only (default on)trailing- move the grid after the price (percent,atr,bollinger; only withstart: immediate, default on)stop_out_percent- how many % the price may go beyond a bound before the stop (default 3); 0 - no stoprestart_after_stop- after the stop, build a new grid from the current price (only withstart: immediate, default on)start- when to start the grid:immediate,deviationorbollinger(defaultimmediate)start_deviation_percent- price deviation from the average for the signal, % (deviationonly, default 5)start_ma_type,start_ma_len,start_ma_source- type, period and price source of the average fordeviation(defaultSMA, 20,close)
Example: a permanent grid (default settings). A new grid strategy is created like this: a ±8% long grid with 20 cells, trailing and a 3% stop with restart.
In basic only long is enabled, a cell is 10% of the balance, and the balance used for the calculation is capped at 1,000 (max_balance).
"grid": {
"range_type": "percent",
"range_percent": 8,
"grid_count": 20,
"spacing": "geometric",
"direction": "long",
"initial_market": true,
"orders_per_side": 10,
"post_only": true,
"trailing": true,
"stop_out_percent": 3,
"restart_after_stop": true,
"start": "immediate"
}
Example: cycles on deviation from the average. A long grid starts when the price drops 5% below SMA 20, and a short grid when the price is 5% above it. For the short, enable use_short in basic.
"grid": {
"range_type": "percent",
"range_percent": 8,
"grid_count": 20,
"spacing": "geometric",
"direction": "both",
"initial_market": true,
"orders_per_side": 10,
"post_only": true,
"stop_out_percent": 3,
"start": "deviation",
"start_deviation_percent": 5,
"start_ma_type": "SMA",
"start_ma_len": 20,
"start_ma_source": "close"
}
Important to know
- Changing the settings rebuilds the grid. If you change the bounds, number of cells, spacing, direction, Bollinger band parameters or start mode, the bot cancels all orders and builds the grid again from the current price. With
initial_market: trueit brings the position to the new grid at market. In signal cycles a grid with an open position continues the cycle in its direction - One symbol - one grid. When building the grid the bot cancels all orders for this symbol on the account
- Position against the direction. If a long grid ends up with a short or vice versa, the grid does not trade and reports in its status that the position must be closed manually
- The trading side is set by
direction, but it must be enabled inbasic.use_longorbasic.use_short, otherwise the grid will not start. Forbothat least one side must be enabled; signals for a disabled side are skipped - Start of a tester run. Until there are enough bars for the average or the bands (
start_ma_lenorbb_len+ 1), the signal is not calculated and the log shows a "not enough bars" warning - Other exits from
options(trailing stop, MA exit and similar) are designed for single-entry strategies. Better not to enable them with the grid
Before running on a real account, test your parameters in the tester over several periods, including declines.
Trading on TradingView signals:
TradingView | Alerts | Webhook
If your strategy is not on the list but you have it in TradingView, the bot can trade on its alerts. The bot receives a signal via webhook and opens or closes a position on the exchange.
The difference from the strategies above: the bot does not calculate signals itself, it executes what TradingView sends. Reaction speed depends on alert delivery.
Detailed alert setup guide: TradingView alerts
Webhook (signals for many coins)
A mode for an external screener or your own signal service: one bot trades all USDT coins on the account at once.
A signal arrives as a POST request to the bot's /w address as JSON with the fields secret (the bot's secret link), symbol (the coin, e.g. BTC) and side (buy or sell).
The bot opens a position with a market order.
link- the secret that must arrive in thesecretfield. Generated automaticallymax_positions- maximum number of positions open at the same time (default 10). A new signal is not executed for a coin that already has a positionallow_trade_minutes- after a trade on a coin, new signals for it are ignored for this many minutes (default 10)ignore_tp_sl_price- do not move take-profit and stop-loss orders already placed if their calculated price has changedskip_leverage_set- do not set leverage on the exchange before entering
Other modes:
Long/Short-bot (experimental stage)
Entry with a limit order from the middle of the close-price channel over n candles, offset by m standard deviations; take-profit another K standard deviations further.
If the entry order is not filled within auto_cancel candles, the levels are recalculated.
n- length of the channel and the standard deviation (default 30)m- entry offset in standard deviations (default 0)K- distance to the take-profit in standard deviations (default 2)auto_cancel- after how many candles to recalculate an unfilled order (default 100)
Close Position Delete Orders
A service mode: the bot closes the open position on the pair with a market order and cancels all orders. Handy for exiting a pair quickly without deleting the bot.
The Off mode - the bot does nothing with the position and orders.
Position closing and common options:
These options are enabled in the options block of the bot settings and work with any strategy. You can enable several at once - whichever condition happens first triggers.
Take-profit and stop-loss
take_profit_long,take_profit_short- take-profit in % of the entry price. Placed as a limit order. 0 - off. Not used in MRS, MRS2, MRS2 FAST, MRS3, Donchian Channel, Grid and RedFlag witheach_tp- they have their own exitstop_loss_long,stop_loss_short- stop-loss in % of the entry price. 0 - offsl_by_order- place the stop-loss as a stop order on the exchange. Without this option the bot watches the price itself and closes the position with a market ordermarket_tp_long,market_tp_short- take-profit by market order: the bot closes the position when the profit reachesmarket_tp_*_value%. No order is placed in advance, so it is not visible in the order book
Trigger stop (breakeven)
When the profit reaches stop_trigger_trigger_long %, the stop is activated. If the price then pulls back by stop_trigger_value_long % from the trigger point, the position is closed.
Example: trigger 3%, stop 2%. The price rose 3% from the entry - the stop is active. If the price pulls back 2% from that point, the position closes at about +1%.
If the values are equal, this moves the stop to breakeven. For short use the stop_trigger_*_short parameters.
MA trailing stop
The position is closed when the price touches the moving average. For long the line is usually below the price, for short above it.
ma_ts_len_long,ma_ts_type_long,ma_ts_source_long,ma_ts_multiplier_long- length, type, source and offset of the MA for long. Length 0 - offma_ts_*_short- the same for short
MA take-profit
The opposite of the trailing stop: long closes when the price rises to the MA line, short when it falls to it. ATR can be used instead of an MA.
ma_tp_long- enable for long.ma_tp_long_type,ma_tp_long_len,ma_tp_long_source,ma_tp_long_multiplier- line settingsma_tp_shortandma_tp_short_*- the same for short
Close on MA crossover
The position is closed when the fast and slow MAs cross, if by then it has the required profit or the loss has reached the stop.
ma_crossing- enable.ma_crossing_by_crosing- close exactly at the moment of the crossoverma_crossing_fast_*,ma_crossing_slow_*- type, length and source of the fast and slow MAma_crossing_min_profit- minimum profit in % to closema_crossing_stop_loss- loss in % at which the position closes on the crossover even without profit. 0 - not usedma_crossing_skip- how many candles after entry not to check for a crossover
Close on the N-th candle (ColorBox)
The position is closed at the close of the N-th candle after entry. You can add a color condition: for example, close long after the 2nd green candle.
use_close_candle_long- enable for longclose_candle_count_long- candle number after entryclose_candle_color_long- candle color:green,redor empty - any color*_short- the same for short
Close on HiDeep signal
HiDeep signals can be used as an exit in any strategy. Long closes on an overbought signal (red ▼), short on an oversold signal (green ▲), if the profit is at least hd_close_min_profit %.
hd_close- enablehd_close_min_profit- minimum profit in % (default 0.5)- The signal is calculated using the settings of the
hdblock
Position filters
A separate filter block in the bot settings (not options) decides whether a long or a short may be opened right now. It works like a temporary use_long / use_short switch: the strategy doesn't enter the blocked side, and exits are never restricted.
Each filter has its own use switch. When several are on, an entry is allowed only if all of them pass.
supertrend- SuperTrend (ATR) trend: long only in an uptrend, short only in a downtrend.factor- ATR multiplier, the higher it is, the less often the trend changes (default 5),atr_len- ATR period (14). In HiDeep, ZZ and MACD Trend it works through the strategy's own logic: HiDeep also closes the position when the trend changes, and MACD Trend also needsuse_trend_filtertrend_ma- MA trend: long only when the close is above the MA, short only below.type,source,len- MA type, source and period (default EMA, close, 200)adx- trend strength by ADX with periodlen(14).min- enter only when ADX is at least this value (default 20),max- only when it is at most this value (for range strategies). 0 - don't checkliquidity- enter only if the average daily turnover (volume × price) overdaysdays (7) is at leastmin_usdt(100000 USDT)time- enter only in the given hours and weekdays, UTC.hours_utc- comma-separated hour ranges, the end is excluded:"8-12,14-20","22-2"- across midnight (default"0-24").weekdays- weekdays, 1 = Monday ... 7 = Sunday:"1-5"(default"1-7")block_adds- don't add to an open position when its side is blocked. Off - filters only restrict opening a new position. In MRS2, MRS2 FAST and MRS3, withblock_addson, a position on the blocked side is closed (Wrong Side)
The filters apply in all strategies except MRS, +1, TV (alerts), TV GRD and DoubleDragon: there enabled filters have no effect, the bot only writes a warning to the log.
Old settings are migrated automatically: trend, trend_power, trend_resistance go to supertrend, and entry_filter from Squeeze and RSI Pullback goes to this block.
Close by time
The time_close block: the position is closed with a market order a set number of candles after entry or on a set day.
enabled- enablebars_count- close N candles after entry. 0 - offuse_day_of_month,day_of_month- close on a set day of the month (1-31). Takes priority overbars_countuse_day_of_week,day_of_week- close on a set day of the week: 0 - Sunday, 1 - Monday ... 6 - Saturday. Takes priority over the other modestime_of_day- for the day-based modes: not earlier than the set UTC time inHH:mmformat. Empty - any time of dayprofit_threshold- profit condition. 1 - off. 1.25 - close only if the profit is at least 25%. 0.5 - close only if the loss is no more than 50%
Pause after a loss or a profit
The bot stops after closing a trade with a loss or a profit: it cancels its orders and stops trading until it is started again. A notification is sent to Telegram.
pause_trading_after_loss,loss_size- stop after a losing trade. Ifloss_sizeis greater than 0 - only when the loss is at least the set %pause_trading_after_profit,profit_size- stop after a profitable trade. Ifprofit_sizeis greater than 0 - only when the profit is at least the set %
Close by account margin
A setting of the API key (the close_by_margin block), not of an individual bot. When the total account balance including unrealized profit has grown relative to the wallet balance to the set level,
all bots of this key reduce their positions. This way you can lock in the overall profit across all pairs at once.
profit- threshold: 1.05 - close when the margin balance is 5% higher than the wallet balance. 1 - offsize- what part of the positions to close: 1 - 100%, 0.5 - halfeach- calculate unrealized profit from the bots' positions instead of taking the margin balance from the exchange
"Like TradingView" mode
like_tv - closing conditions are checked against the High/Low of the closed candle, the way the TradingView strategy tester does it, instead of the current price.
Helps get results on the live market close to the TradingView backtest.
Updated: