Skip to main content

Simple Moving Average and MACD

Simple Moving Average and MACD strategy behavior

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_PCT below average buy price;
  • SMM_SMA_STOP_BUFFER_PCT below 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

SettingDescription
BUY_ENABLEDEnables initial and re-entry buys.
SELL_ENABLEDEnables exits.
PERIODCandle period; default 15 minutes.
TRADING_LIMITCompatibility 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_LIMITFor USDT-BTC, the amount of USDT used per entry or addition.
SMM_MAX_POSITION_MULTIPLIERMaximum total exposure in trading-limit units.
FUNDS_RESERVEFor USDT-BTC, the amount of USDT the bot must leave unused.
KEEP_QUOTEFor USDT-BTC, the amount of BTC the strategy must not sell.
MIN_VOLUME_TO_BUYGeneral minimum buy value. For USDT-BTC, this value is in USDT.
MIN_VOLUME_TO_SELLGeneral minimum sell value. For USDT-BTC, this value is in USDT.
SMM_MIN_ORDER_VALUEStrategy minimum entry value. For USDT-BTC, this value is in USDT.
SMM_MIN_SELL_VALUEStrategy minimum exit value. For USDT-BTC, this value is in USDT.
GAINGeneral gain fallback retained in configuration.
SMM_COOLDOWN_MSDelay between actions.
SMM_ENFORCE_COOLDOWN_IN_BACKTESTApplies cooldown in backtests.
SMM_MAX_SPREAD_PCTRelative entry spread ceiling.
SMM_MAX_SPREAD_ABSOLUTEOptional absolute ceiling; 0 disables it. For USDT-BTC, this value is in USDT.
SMM_NEWS_BLOCKManually blocks entries.
SMM_NEWS_BLOCK_UNTILBlocks entries until the configured time.

Signal and re-entry

SettingDescription
SMM_SMA_LENGTHTrend and retest SMA length.
SMM_MACD_FASTFast MACD length.
SMM_MACD_SLOWSlow MACD length.
SMM_MACD_SIGNALMACD signal length.
SMM_USE_DAMIANI_FILTEREnables the ATR-ratio activity filter.
SMM_DAMIANI_FAST_ATRFast ATR length.
SMM_DAMIANI_SLOW_ATRSlow ATR length.
SMM_DAMIANI_THRESHOLDMinimum fast/slow ATR ratio.
SMM_REENTRY_ENABLEDEnables SMA-retest signal recognition.
SMM_REENTRY_BUYS_ENABLEDAllows retest signals to add to an open position.
SMM_MAX_REENTRIESMaximum additions in the current trend.
SMM_REENTRY_TOLERANCE_PCTAllowed distance around the SMA for a retest; also defines an extended close after a large bar.
SMM_LARGE_BAR_PIPSLarge-candle threshold in pip mode.
SMM_LARGE_BAR_PCTLarge-candle threshold in percentage mode.

Targets and protection

SettingDescription
SMM_USE_PIPSSelects pip target and large-bar distances.
SMM_PIP_SIZEFor USDT-BTC, the USDT value represented by one pip.
SMM_FIRST_TARGET_PIPSFirst target in pip mode.
SMM_SECOND_TARGET_PIPSSecond target in pip mode.
SMM_FIRST_TARGET_PCTFirst target in percentage mode.
SMM_SECOND_TARGET_PCTSecond target in percentage mode.
SMM_FIRST_PARTIAL_SELL_PCTRemaining position percentage sold at target one.
SMM_SECOND_PARTIAL_SELL_PCTRemaining position percentage sold at target two.
SMM_MIN_NET_GAIN_PCTIntended gain beyond fee break-even.
SMM_USE_PROTECTIONEnables the ratcheting stop.
SMM_STOP_PCTFixed stop distance from average buy price.
SMM_SMA_STOP_BUFFER_PCTStop distance below the SMA.
SMM_MOVE_STOP_TO_BREAKEVENRaises the stop after the first completed target stage.
SMM_EXIT_ON_MACD_FLIPEnables profitable exit on bearish histogram cross.
SMM_EXIT_ON_SMA_LOSSEnables profitable exit below SMA with negative histogram.

Backtesting

SettingDescription
BF_SINCEBacktest start.
BF_UNTILBacktest end.
DEEP_TESTINGEnables 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.