Simple Moving Average and MACD

Simple Moving Average and MACD uses a long SMA as trend support and the MACD histogram as momentum confirmation. It can enter on a fresh SMA or histogram cross, avoid oversized breakout candles, and add on later SMA retests.
Two profit levels support scaled exits. Optional protection follows the SMA and can move to break-even after the first target.
warning
This strategy can add to an existing position when re-entry buys are enabled. Set the re-entry count and maximum position multiplier deliberately before live use.
Initial entry
An initial buy needs price above SMM_SMA_LENGTH, a positive MACD histogram, and either:
- price just crossed above the SMA; or
- the MACD histogram just crossed above zero.
MACD uses SMM_MACD_FAST, SMM_MACD_SLOW, and SMM_MACD_SIGNAL.
The strategy measures the current candle’s high-low range. If that range exceeds SMM_LARGE_BAR_PCT or SMM_LARGE_BAR_PIPS and price closes farther than SMM_REENTRY_TOLERANCE_PCT above the SMA, it waits for a retrace instead of chasing the bar.
Volatility filter
Enable SMM_USE_DAMIANI_FILTER to compare short and long ATR readings. The short/long ratio must reach SMM_DAMIANI_THRESHOLD.
SMM_DAMIANI_FAST_ATR and SMM_DAMIANI_SLOW_ATR control the two ATR lengths. This is a simplified volatility ratio: it seeks enough recent activity, but does not itself determine bullish direction.
SMA re-entries
Enable SMM_REENTRY_ENABLED to recognize bullish retests after a long trend signal. A retest candle must reach the SMA within SMM_REENTRY_TOLERANCE_PCT, close above it, and retain bullish MACD behavior.
SMM_REENTRY_BUYS_ENABLED determines whether those signals may add to an existing position. SMM_MAX_REENTRIES limits additions, and SMM_MAX_POSITION_MULTIPLIER caps total position value relative to one trading limit.
Turning off re-entry buys keeps the signal logic but prevents position additions.
Two targets
Target distances use SMM_FIRST_TARGET_PCT and SMM_SECOND_TARGET_PCT, or their pip equivalents when SMM_USE_PIPS is enabled.
SMM_FIRST_PARTIAL_SELL_PCT and SMM_SECOND_PARTIAL_SELL_PCT set how much of the remaining position each level sells. At default 100% for the first target, the second target normally has no remaining balance to manage. Use a smaller first percentage if you intend a true two-stage exit.
Both targets respect fees and SMM_MIN_NET_GAIN_PCT.
Stop and technical exits
The calculated stop is the closer of:
SMM_STOP_PCTbelow average buy price;SMM_SMA_STOP_BUFFER_PCTbelow the SMA.
It ratchets upward with the SMA. Enable SMM_USE_PROTECTION to make it executable. SMM_MOVE_STOP_TO_BREAKEVEN raises it to entry after a target stage is completed.
SMM_EXIT_ON_MACD_FLIP enables a profitable exit when the histogram crosses below zero. SMM_EXIT_ON_SMA_LOSS exits profitably when price is below the SMA and the histogram is negative.
Good market conditions
This system generally works best in liquid, directional markets where a long SMA acts as support, MACD expands positively, and pullbacks retest rather than break the SMA.
Avoid choppy SMA crossings, weak volatility ratios, and oversized impulse candles with no orderly retrace. Re-entry is most useful in a persistent trend, not a deteriorating range.
Creating the strategy
Create a spot strategy and choose Simple Moving Average and MACD for both methods. Start with the default 15-minute period.
Test initial entries before enabling additions. Decide on the intended maximum exposure, make the first partial percentage smaller than 100 if a second target is desired, and evaluate protection with realistic gap and slippage assumptions.
Strategy settings
Trading and exposure
| Setting | Description |
|---|---|
BUY_ENABLED | Enables initial and re-entry buys. |
SELL_ENABLED | Enables exits. |
PERIOD | Candle period; default 15 minutes. |
TRADING_LIMIT | Compatibility fallback only. It is ignored while the strategy-specific trading limit contains a positive value. Configure the strategy-specific setting for normal use. For USDT-BTC, this value is in USDT. |
SMM_TRADING_LIMIT | For USDT-BTC, the amount of USDT used per entry or addition. |
SMM_MAX_POSITION_MULTIPLIER | Maximum total exposure in trading-limit units. |
FUNDS_RESERVE | For USDT-BTC, the amount of USDT the bot must leave unused. |
KEEP_QUOTE | For USDT-BTC, the amount of BTC the strategy must not sell. |
MIN_VOLUME_TO_BUY | General minimum buy value. For USDT-BTC, this value is in USDT. |
MIN_VOLUME_TO_SELL | General minimum sell value. For USDT-BTC, this value is in USDT. |
SMM_MIN_ORDER_VALUE | Strategy minimum entry value. For USDT-BTC, this value is in USDT. |
SMM_MIN_SELL_VALUE | Strategy minimum exit value. For USDT-BTC, this value is in USDT. |
GAIN | General gain fallback retained in configuration. |
SMM_COOLDOWN_MS | Delay between actions. |
SMM_ENFORCE_COOLDOWN_IN_BACKTEST | Applies cooldown in backtests. |
SMM_MAX_SPREAD_PCT | Relative entry spread ceiling. |
SMM_MAX_SPREAD_ABSOLUTE | Optional absolute ceiling; 0 disables it. For USDT-BTC, this value is in USDT. |
SMM_NEWS_BLOCK | Manually blocks entries. |
SMM_NEWS_BLOCK_UNTIL | Blocks entries until the configured time. |
Signal and re-entry
| Setting | Description |
|---|---|
SMM_SMA_LENGTH | Trend and retest SMA length. |
SMM_MACD_FAST | Fast MACD length. |
SMM_MACD_SLOW | Slow MACD length. |
SMM_MACD_SIGNAL | MACD signal length. |
SMM_USE_DAMIANI_FILTER | Enables the ATR-ratio activity filter. |
SMM_DAMIANI_FAST_ATR | Fast ATR length. |
SMM_DAMIANI_SLOW_ATR | Slow ATR length. |
SMM_DAMIANI_THRESHOLD | Minimum fast/slow ATR ratio. |
SMM_REENTRY_ENABLED | Enables SMA-retest signal recognition. |
SMM_REENTRY_BUYS_ENABLED | Allows retest signals to add to an open position. |
SMM_MAX_REENTRIES | Maximum additions in the current trend. |
SMM_REENTRY_TOLERANCE_PCT | Allowed distance around the SMA for a retest; also defines an extended close after a large bar. |
SMM_LARGE_BAR_PIPS | Large-candle threshold in pip mode. |
SMM_LARGE_BAR_PCT | Large-candle threshold in percentage mode. |
Targets and protection
| Setting | Description |
|---|---|
SMM_USE_PIPS | Selects pip target and large-bar distances. |
SMM_PIP_SIZE | For USDT-BTC, the USDT value represented by one pip. |
SMM_FIRST_TARGET_PIPS | First target in pip mode. |
SMM_SECOND_TARGET_PIPS | Second target in pip mode. |
SMM_FIRST_TARGET_PCT | First target in percentage mode. |
SMM_SECOND_TARGET_PCT | Second target in percentage mode. |
SMM_FIRST_PARTIAL_SELL_PCT | Remaining position percentage sold at target one. |
SMM_SECOND_PARTIAL_SELL_PCT | Remaining position percentage sold at target two. |
SMM_MIN_NET_GAIN_PCT | Intended gain beyond fee break-even. |
SMM_USE_PROTECTION | Enables the ratcheting stop. |
SMM_STOP_PCT | Fixed stop distance from average buy price. |
SMM_SMA_STOP_BUFFER_PCT | Stop distance below the SMA. |
SMM_MOVE_STOP_TO_BREAKEVEN | Raises the stop after the first completed target stage. |
SMM_EXIT_ON_MACD_FLIP | Enables profitable exit on bearish histogram cross. |
SMM_EXIT_ON_SMA_LOSS | Enables profitable exit below SMA with negative histogram. |
Backtesting
| Setting | Description |
|---|---|
BF_SINCE | Backtest start. |
BF_UNTIL | Backtest end. |
DEEP_TESTING | Enables deeper backtesting. |
Practical tuning directions
Treat re-entry settings as position sizing controls, not just signal settings. Test worst-case exposure with every permitted addition filled.
If the system waits after good breakout candles, review the large-bar threshold and retrace tolerance. Raising the threshold allows more direct entries but increases the chance of chasing.
Important limitations
- Re-entry buys increase exposure and change average buy price.
- A 100% first partial normally leaves nothing for target two.
- The ATR ratio measures activity, not direction.
- The SMA-following stop executes only with protection enabled.
- Technical exits wait for fee-aware profit.
- News blocking is manual.
Simple Moving Average and MACD works best when the SMA is visibly respected. Repeatedly adding around a line that no longer acts as support is not productive re-entry.