Advanced Strategy Parameters
Spread Strategy and Its Parameters
To make the Spread strategy appear in the list of strategies in the Moonbot terminal, you must activate the paid Autotrading extension package.
⚠️ Attention! The Spread strategy is associated with very high risks. Use it without auto-buy, as a detection tool, to understand how it works. Only after fully understanding it should you configure it for real trading.
Example of the Spread strategy operation during the listing of the DODO coin:
By spread we mean active trading within the zone between the ASK and BID boundaries, defined by time and price range.
General Parameters
-
TimeInterval: field for specifying the time interval in whole seconds over which the calculation is performed (minimum value 1 second);
-
TradesDensity: field for specifying trade density over time, in percent. To calculate trade density, the TimeInterval is divided into small 200 ms segments, and the ratio between segments containing at least 2 trades with different prices and “empty” segments (without trades) is calculated. For example, TradesDensity = 100 (%) means that trades with different prices occur at least every 200 ms;
-
TradesDensityPrev: field for specifying trade density before detection, calculated over the previous interval equal to TimeInterval. This helps filter out coins that were initially inactive. For pump scenarios, this parameter should be set to 0, since inactive coins (with low volatility before the spread appears) are required;
-
TradesCountMin: field for specifying the minimum number of trades every 200 ms throughout the entire detection interval. If 0, not applied. A high value may significantly limit detections, as it will select only environments with very high trade density;
-
PriceIntervals: field for specifying the number of equal segments into which TimeInterval is divided to calculate the price range. TimeInterval is divided into PriceIntervals parts; for each part, the maximum and minimum price and the delta (difference) between them are calculated;
-
PriceIntervalShift: field for specifying an integer value from 0 to 5. This setting filters out detections caused by single spikes. Calculation principle: the analysis interval is shifted to the left by 200 ms, PriceIntervalShift times. Each time, detection conditions are recalculated for the shifted interval. The final detection will trigger only if conditions are met on all shifted intervals. If 0, recalculation is not performed;
-
PriceSpread: field for specifying the minimum spread size in percent required for detection. Detection occurs if, in each part of PriceIntervals, the price range exceeds PriceSpread;
-
IntervalsForBuySpread: field for specifying the number of the latest segments from PriceIntervals used to calculate the minimum and maximum spread price. If 0, calculation is performed over the entire TimeInterval;
-
BuyPriceInSpread: field for specifying the percentage at which to place the Buy order within the spread. For long positions, the percentage is measured upward from the minimum price; for short positions, downward from the maximum price.
Examples -
If BuyPriceInSpread = 0 (%), the long Buy order will be placed at the minimum price within the spread;
-
If BuyPriceInSpread = 50 (%), the long Buy order will be placed in the middle of the spread;
-
If BuyPriceInSpread = -100 (%), the short Buy order will be placed above by double the spread distance;
Please note! The buyPrice parameter from the Buy conditions tab also affects the purchase price. In this case, BuyPriceInSpread defines the “base price,” from which buyPrice is then calculated; -
SellPriceInSpread: field for specifying the percentage at which to place the Sell order within the spread. Similar to BuyPriceInSpread, but defines the preset selling price based on the spread. Unlike BuyPriceInSpread, the selling price is taken as the higher of either SellPrice or the spread-based price. In other words, if SellPrice is smaller than the spread value, for example SellPrice = 0, then the sale is placed based on the spread. If greater, the sale is placed based on SellPrice. Modifiers also affect the selling price;
-
BuyOrderReduce: field for specifying the interval in milliseconds over which the average trading volume is calculated. The strategy will place an order no larger than the average volume. By default, BuyOrderReduce = 100 (ms). If 0, not applied;
Volume is calculated as follows: the total volume of all buy and sell trades (BV + SV) over the TimeInterval is summed and divided by BuyOrderReduce. For example, if TimeInterval = 5 (seconds), i.e., 5000 ms, BuyOrderReduce = 100 (ms), and the total trade volume over 5 seconds was $10,000, then the average volume per 100 ms equals 10000 / 5000 ms * 100 ms = $200. In this case, the strategy will place a Buy order no larger than $200.
In other words, we calculate the average volume over 100 ms / 10 ms / 5 ms — this becomes the maximum order size the strategy will place.
The order size reduction function can be seen in the log with an entry such as:
IOTA: [1] (40) Buy order reduced: 1000.00$ => 23$ (Vol: 23$)
In this log, OrderSize in the strategy was set to $1000, but the average trading volume over 100 ms was only $23, so the strategy placed a Buy order of $23. -
MinReducedSize: field for specifying the minimum Buy order size in USDT after applying the BuyOrderReduce parameter, below which the Buy order will not be placed. For example, if MinReducedSize = 50 (USDT) and after applying BuyOrderReduce it is calculated that only a $23 Buy order can be placed, then since $23 is less than $50, the $23 Buy order will not be placed. If 0, not applied.
-
SpreadRepeatIfProfit: field for specifying the relative percentage from the buy price to the sell price at which the strategy is allowed to place a repeated Buy order within 1 second after detection (no later). That is, a repeated Buy order can be placed if the current price has risen and becomes higher than the buy price by SpreadRepeatIfProfit percent toward the sell price, and this occurs within 1 second after detection. If 0, repeated orders are not placed.
For example, if SpreadRepeatIfProfit = 100 (%), the current price must reach the Sell order price and the position must be sold, after which the strategy is allowed to place a repeated Buy order.
If SpreadRepeatIfProfit = 50 (%), the current price must reach half the distance between the buy price and the Sell order price, and then the strategy will be allowed to place a repeated Buy order. No more than 5 repeated Buy orders are allowed in the Spread strategy due to an internal code limitation. -
SpreadFlat: YES/NO checkbox. If YES, the strategy will try to detect the spread in a horizontal channel.
-
Spread_BV_SV_Time: field for specifying the analysis interval in milliseconds. If 0 is set, not applied.
-
Spread_BV_SV_Max: field for specifying the maximum ratio of buys (BV) to sells (SV). If 0 is set, not applied.
-
Spread_BV_SV_Min: field for specifying the minimum ratio of buys (BV) to sells (SV). If 0 is set, not applied.
If the strategy is set to short, the ratio is automatically inverted: for short, the ratio of sells (SV) to buys (BV) is used.
Example: Spread_BV_SV_Time = 1500 (one and a half seconds).
Over the last 1.5 seconds there were Buy trades totaling $500 and Sell trades totaling $1000.
The BV/SV ratio will be 500/1000 = 0.5 for long, or 1000/500 = 2 for short, respectively. -
SpreadPolarityMin: field for specifying the minimum boundary of the spread polarity range.
-
SpreadPolarityMax: field for specifying the maximum boundary of the spread polarity range.
Spread polarity is the direction of the spread; its numeric measure can range from -100 (strictly down) to +100 (strictly up).
Example of a Spread strategy
TimeInterval = 5 (sec.)
TradesDensity = 100
PriceIntervals = 5
PriceSpread = 0.3 (%)
IntervalsForBuySpread = 2
BuyPriceInSpread = 5 (%)
SellPriceInSpread = 100 (%)
BuyOrderReduce = 100 (ms).
With these parameters, over the last 5 seconds, each second must have a price fluctuation greater than 0.3%. For calculating Buy and Sell orders, the last 2 intervals will be used (IntervalsForBuySpread = 2). The Buy order will be placed at a relative +5% from the minimum spread value, and the Sell order at a relative +100%, i.e., at the spread maximum.
At the same time, if the reduced volume per 100 ms is smaller than the Buy order size specified in the strategy OrderSize parameter, the Buy order will be placed equal to this reduced volume per 100 ms.
-
It is VERY important to use Latency filters in the Spread strategy, since price values for spread detection are taken from trades (crosses on the chart). If prices arrive with delay, detection may trigger when the price has already risen sharply!
-
If the Buy order is partially filled, the strategy cancels it and places the entire executed volume for sale, similar to the MoonShot strategy.
-
Detection conditions are recalculated once every half second.
-
The strategy accounts for detection modifiers (the modifier affects PriceSpread).
-
It is recommended to use this strategy with a short EMA filter, for example EMA(30,2), to determine price rise or fall and place a high Sell order for short or long respectively.
-
If multiple Spread strategies are enabled in the Moonbot terminal, detections and order placement will occur for each of them, since the Spread strategy always has IndependentSignals = YES enabled on the Main tab.
-
You can view the Spread strategy detection parameters on coin charts. To do this, enable the Extended Debug Mode checkbox on the Settings → Advanced → System tab.
D: trades density;
dP: price range over the entire TimeInterval;
Vol: reduced (normalized) volume;
Spread: actual spread, in percent;
N: number of segments on which the spread was detected (the last two appear on the chart only at the moment of detection).
These values are also shown in the detection line in the report: