Skip to main content

Simple MACD and EMA

Simple MACD and EMA strategy behavior

Simple MACD and EMA looks for a recovery through an EMA while MACD is also improving. It is designed to catch a move that first traded below both references, then regained the EMA as MACD approached or crossed its zero line.

The exit plan is built around recent structure, an EMA-following stop, and a risk/reward target. Protection is optional, while profitable EMA and MACD reversals can close the position independently.

warning

The target is always part of this strategy. SME_USE_PROTECTION controls whether the calculated stop may realize a loss; it does not disable the target or profitable technical exits.

Entry sequence

A long setup needs four pieces:

  1. Within SME_SETUP_LOOKBACK, price was below SME_EMA_LENGTH and MACD was below zero.
  2. The current close crosses upward through the EMA.
  3. The close reaches the optional entry buffer above that EMA.
  4. MACD either crossed above zero within SME_MACD_CROSS_LOOKBACK, or is still below zero but rising with an improving histogram.

The last condition lets the strategy enter while a bullish zero-line cross is visibly developing, rather than requiring it to be complete.

SME_ENTRY_BUFFER_PCT sets the clearance above the EMA in percentage mode. In pip mode, SME_ENTRY_BUFFER_PIPS is used instead. A larger buffer demands a more decisive recovery but enters farther from the EMA.

The strategy holds one position at a time and does not average down.

EMA and MACD controls

SME_EMA_LENGTH is both the entry reference and the basis for the following stop.

SME_MACD_FAST, SME_MACD_SLOW, and SME_MACD_SIGNAL define MACD. Keep the slow length above the fast length. Shorter values react earlier but also produce more zero-line changes in sideways markets.

The two lookbacks serve different purposes:

  • SME_SETUP_LOOKBACK remembers the earlier below-EMA, negative-MACD condition;
  • SME_MACD_CROSS_LOOKBACK accepts a recent completed MACD zero cross.

Widening both can combine events that belong to different market swings, so tune them separately.

Stop mode and trailing

The initial stop depends on SME_STOP_MODE:

  • conservative places it one configured stop buffer below the EMA;
  • aggressive uses the recent low from SME_SWING_LOOKBACK when that low is valid.

“Aggressive” here can create a structurally different and sometimes wider stop; always verify the actual distance on the pair.

After entry, the calculated stop follows the EMA at SME_TRAIL_BUFFER_PCT or SME_TRAIL_BUFFER_PIPS below it. It only ratchets upward. Enable SME_USE_PROTECTION to make this stop executable.

SME_MOVE_STOP_TO_BREAKEVEN raises the stored stop to entry after the target event has been processed.

Risk/reward target and partial amount

The target is entry price plus initial risk multiplied by SME_RISK_REWARD. It is raised when needed to cover fees and SME_MIN_NET_GAIN_PCT.

SME_PARTIAL_SELL_PCT controls how much is sold when that target is reached. At the default 100%, it is a full exit. With a smaller value, the remainder stays open and the target is marked as taken; EMA/MACD exits or protection manage what remains.

Technical exits

Enable SME_EXIT_ON_MACD_FLIP to exit profitably after MACD crosses below zero.

A close crossing below the EMA is also a built-in profitable exit and has no separate switch. Both technical exits wait for the fee-aware profitable floor. Only enabled protection can deliberately close at a loss.

Good market conditions

This strategy generally suits:

  • liquid pairs with small spreads;
  • recoveries after a controlled pullback;
  • an EMA that acts as a meaningful dividing line;
  • MACD improving from negative territory;
  • enough range for the risk/reward target.

Avoid flat markets where price repeatedly crosses the EMA and MACD hovers around zero. Large buffers reduce some noise but can worsen entry price.

Creating the strategy

Create a spot strategy and choose Simple MACD and EMA as both methods. Start on the default 15-minute period in backtesting or paper trading.

First tune the EMA and MACD relationship, then the two signal lookbacks. Choose pip or percentage distances, inspect conservative versus aggressive stops, and only then tune risk/reward and partial sizing.

Strategy settings

Trading and safeguards

SettingDescription
BUY_ENABLEDEnables entries.
SELL_ENABLEDEnables all 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.
SME_TRADING_LIMITFor USDT-BTC, the amount of USDT used for an entry.
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.
SME_MIN_ORDER_VALUEStrategy minimum entry value. For USDT-BTC, this value is in USDT.
SME_MIN_SELL_VALUEStrategy minimum exit value. For USDT-BTC, this value is in USDT.
GAINGeneral gain fallback retained in configuration.
SME_COOLDOWN_MSDelay between actions.
SME_ENFORCE_COOLDOWN_IN_BACKTESTReproduces the cooldown in backtests.
SME_MAX_SPREAD_PCTRelative spread ceiling for entries.
SME_MAX_SPREAD_ABSOLUTEOptional absolute spread ceiling; 0 disables it. For USDT-BTC, this value is in USDT.
SME_NEWS_BLOCKManually blocks entries.
SME_NEWS_BLOCK_UNTILBlocks entries until the configured time.

Signal

SettingDescription
SME_EMA_LENGTHEMA used for setup, trigger, trail, and technical exit.
SME_MACD_FASTFast MACD EMA length.
SME_MACD_SLOWSlow MACD EMA length.
SME_MACD_SIGNALMACD signal-line length.
SME_MACD_CROSS_LOOKBACKCandles in which a bullish MACD zero cross remains acceptable.
SME_SETUP_LOOKBACKCandles searched for the earlier below-EMA, negative-MACD setup.
SME_ENTRY_BUFFER_PIPSRequired EMA clearance in pip mode.
SME_ENTRY_BUFFER_PCTRequired EMA clearance in percentage mode.

Risk and exit

SettingDescription
SME_USE_PIPSSelects pip rather than percentage distances.
SME_PIP_SIZEFor USDT-BTC, the USDT value represented by one pip.
SME_STOP_BUFFER_PIPSInitial EMA stop buffer in pip mode.
SME_TRAIL_BUFFER_PIPSEMA-following stop buffer in pip mode.
SME_STOP_PCTInitial EMA stop buffer in percentage mode.
SME_TRAIL_BUFFER_PCTEMA-following stop buffer in percentage mode.
SME_STOP_MODEChooses EMA-buffer (conservative) or recent-low (aggressive) initial stop.
SME_SWING_LOOKBACKCandles searched for the aggressive recent-low stop.
SME_PARTIAL_SELL_PCTPosition percentage sold at the risk/reward target.
SME_RISK_REWARDInitial-risk multiplier used for the target.
SME_MIN_NET_GAIN_PCTIntended gain beyond round-trip fee break-even.
SME_USE_PROTECTIONAllows the calculated stop to execute.
SME_MOVE_STOP_TO_BREAKEVENRaises the stop to entry after the target event.
SME_EXIT_ON_MACD_FLIPEnables profitable exit on bearish MACD zero cross.

Backtesting

SettingDescription
BF_SINCEBacktest start.
BF_UNTILBacktest end.
DEEP_TESTINGEnables deeper backtesting mode.

Practical tuning directions

If entries are too early, increase the entry buffer or require a more recent setup. If they are too late, reduce the buffer before making MACD extremely fast.

Use percentage mode for instruments with very different price scales. Use pip mode only when SME_PIP_SIZE matches the market’s price scale (USDT per BTC on USDT-BTC).

When using a partial target, test the remainder explicitly: its eventual outcome depends on the EMA trail, profitable signal exits, and whether protection is enabled.

Important limitations

  • EMA and MACD can whipsaw around flat levels.
  • A developing MACD zero cross can reverse before completion.
  • “Aggressive” stop mode is not guaranteed to be tighter.
  • The EMA exit has no user switch and waits for profit.
  • A calculated stop does nothing while protection is disabled.
  • News blocking is manual.
  • Live fills can differ from backtests.

Simple MACD and EMA works best when the earlier weak phase and the current recovery are visibly part of the same move. Lookbacks should preserve that relationship, not merely increase the number of trades.