Development of a MACD-based trading bot for cryptocurrencies

Manually tracking signals at trend reversals consumes time and nerves. We develop a turnkey MACD bot: we configure signal logic, filters, and risk management for your trading style. We reduce the time spent monitoring positions and lower drawdown through execution discipline.

Blockchain Development Services

Frequently Asked Questions

Latest works

  • Development of a web application for FEEDME
    Development of a web application for FEEDME
    1376
  • Development of an online store for the company FURNORO
    Development of an online store for the company FURNORO
    1350
  • B2B Advance company logo design
    B2B Advance company logo design
    796
  • Development of a web application for Enviok
    Development of a web application for Enviok
    1088
  • AIDER company logo development
    AIDER company logo development
    1034
  • CRM development for Chasseurs
    CRM development for Chasseurs
    1130

MACD bot breaks on trend reversals: where the bottleneck is

MACD is built on moving averages, so the signal by its nature confirms a move after it has already started.

On a trend reversal, the crossing of the fast and signal lines forms with a lag: by the time of entry, the price has already covered a noticeable part of the impulse, and the bot opens a position in a direction that has already exhausted itself.

The second hole is false entries in a sideways market. In a narrow range, the lines cross dozens of times, every point looks like an entry, but in fact it is noise: a series of small protective triggers eats the deposit faster than one large loss.

On top of that comes slippage during execution — on a sharp move, order density drops, and the actual entry price diverges from the calculated one not in the position's favor, and on thin pairs this divergence repeats from trade to trade.

The logical answer is to keep the bot but manage the position manually.

This does not close the bottleneck: a human reacts slower than the indicator, physically cannot keep several instruments in view at once, and after a series of losses starts interfering where interference only harms. The hole simply moves from the code to the operator and becomes non-reproducible.

The lag itself is not cured by changing the period. We break down how this is closed at the logic level: by determining market state, confirming the signal on a higher timeframe, and controlling execution quality.

What a MACD bot provides: measurable effects of automation

Transferring MACD logic into a bot is measured not by the “smartness” of signals but by three values: drawdown depth, time from signal to trade, and the share of trades executed strictly according to the rules.

We assemble a prototype of the strategy in TradingView, but in the live market it is automatic execution that delivers the values — let's break down how.

Drawdown: risk is calculated before entry

The bot takes position size from the instrument's current volatility, so in a calm and in a wide market it differs by multiples. The stop is placed together with the order, not after a loss, and after a series of unsuccessful trades, trading stops until the next day. Drawdown depth stops depending on who is watching the screen.

Reaction speed to the signal

The signal is calculated on candle close: while a manual trader is weighing the entry, the bot places an order in seconds. The delay consists only of the exchange response and the communication channel — we measure it and keep it constant. On a MACD reversal, this changes the entry price more noticeably than the choice of indicator.

Execution discipline

Filter by higher timeframe, one trade per signal, no stop movement and no manual “adding” — the rules are set in the configuration and do not depend on mood.

Every trade is written to a journal with the entry reason and parameters, so it shows where the strategy loses, not where it got lucky on one trade.

Comparison of execution modes and strategy types

The strategy execution mode determines how the bot reacts to the crossing of MACD lines: entry on the signal event, entry on candle close, or a pending order on a pullback to the signal line.

This determines trade frequency and sensitivity to market noise — so we compare the options by market conditions, not by “better in general.”

A separate slice is spot and leveraged trading: spot limits risk to position size, leverage adds liquidation and requires calculating margin for volatility.

Signal filters — higher timeframe confirmation, volatility, volume, a ban on entries in a sideways market — cut some trades but raise the share of profitable ones.

Option When it is appropriate Where the limit is
Trend-following Directional movement, higher timeframe confirms Sideways market: a series of false crossings and accumulation of commissions
Counter-trend Wide channel, price returning to the mean Prolonged trend: rare but deep losses
With signal filters Volatile pairs where noise screening matters more Entry delay — part of the move is missed
With position averaging Range with a clear boundary A trend against the position with leverage wipes out the deposit
Spot without leverage First launch, long holds Capital limits profitability and trade frequency
With leverage Short trades, tight stop, margin calculation Liquidation on a sharp spike, margin control required

Combinations also work: counter-trend on the higher timeframe as a filter for trend entries on the lower timeframe. Before launch, we run each option on history with real commissions and slippage — this shows where the strategy breaks and what drawdown buffer remains.

Development stages: from data audit to handover of regulations

Work starts not with code but with breaking down the hypothesis: MACD compares the fast and slow moving averages, but the mechanics itself does not answer where to enter, what to limit the loss with, and in which market the technique works at all. Next is the order in which the project proceeds.

  1. Trading hypothesis audit: we fix the source of edge, the position holding horizon, and the market regimes where the technique makes sense. Hypotheses that fail this review are cut before code.
  2. Signal scheme: we describe how the crossing of the MACD line with the signal line turns into an order — trend filters, entry and exit rules, position size, stop level.
  3. Indicator parameter tuning: we select the periods of the moving averages and signal line so that the signal remains stable rather than fitted to one lucky segment.
  4. Strategy backtesting on history: a run over a long interval — growth, decline, sideways — accounting for commissions and slippage. We look at drawdown, share of profitable trades, and behavior on data that did not participate in fitting.
  5. Test launch: the bot trades with minimal volume, we compare signal calculation with previous results, order execution time, and behavior during connection drops.
  6. Industrial launch of the bot: position and daily loss limits, a journal of every order, state monitoring, and stopping with one command.
  7. Handover of regulations: logic description, launch and stop instructions, parameter change procedure, and control points — the system lives without us.

Deliverables: configurations, schemes, and regulations

After launch, the entire loop remains with the client: the MACD bot is handed over not as a “black box” but as a set of artifacts that your team can read, edit, and pass on without reconstructing code from logs. The deliverables include everything needed for independent operation and changing the contractor.

  • Trading strategy configuration — a separate file with periods of the fast and slow moving averages, the signal line, the working timeframe, the list of pairs, and entry/exit thresholds. Editing parameters does not require rebuilding the code or going through checks again.
  • Signal logic scheme — a diagram from candle arrival to order placement: where moving averages are calculated, how false crossings are filtered, and what counts as confirmation.
  • Risk management scheme — position size based on current deposit, limit per trade and per portfolio, stop-loss and take-profit, maximum simultaneous positions, behavior when the connection to the exchange drops.
  • Order handling rules — order types, partial fill processing, retries, and protection against duplicate trades during network failures.
  • Deployment scripts — bot environment, keys with trading-only permissions, no withdrawal rights, scheduled start and stop.
  • Bot documentation — module descriptions, log formats, breakdown of typical failures, and procedure: how to find the cause and which parameter to change.
  • Support regulations — which metrics we collect, at which deviations an alert arrives, who responds and within what timeframe, and how we roll back to the previous configuration.

All of this sits in your repository and survives a team change: the risk management rules and logic scheme are described so that a new engineer can enter the project without restoring context from chat.

Case study: reworking signal logic and reducing drawdown

A team came to us that traded spot through the exchange API on Bybit. The bot was built on the classic MACD crossing: fast line above the signal line — entry, below — exit from the position.

On trending sections, the logic worked, but in a sideways market it produced series of 8–12 false entries in a row, and each such series closed with a stop.

What was changed in the signal logic

Analysis of trade history showed: more than half of the entries fell within a narrow range where MACD crosses the signal line with minimal amplitude.

The crossing was kept, but surrounded with confirmations — histogram slope, volatility filter, and alignment with the direction of the higher timeframe.

Entry is executed on candle close, not at the moment of touch, and re-entry in the same direction is blocked until the state resets.

Metrics before and after

Cutting out low-volatility sections reduced the number of trades by 2.6 times — fewer commissions and less slippage on each series. The share of profitable trades grew from 41% to 58%, and maximum drawdown decreased from 34% to 12% on the same historical segment.

The transition took three weeks: five days — backtesting on historical data and threshold selection, two weeks — reworking the logic and checking on a holdout sample, four days — parallel launch on a small share of capital. Trading did not stop for a single day.

How a trading bot differs from manual position management

The bot makes a decision at candle close: the MACD histogram has crossed the signal line, the condition is confirmed by volume — the order goes to the exchange in fractions of a second.

At the same time, a human recalculates risk, selects position size, and enters on the next bar, at a different price. The difference in speed turns into a difference in entry price, and over a distance of hundreds of trades this is visible in the final result.

The second difference is execution discipline. The bot does not move the stop, does not average a losing position, and does not change size after a series of failures: a rule once written into the logic works the same on the first and the hundredth trade. A human makes the same decisions under pressure and deviates from the plan — usually for the worse.

The third is hypothesis verifiability.

The logic is run on history and on a separate forward segment: you can see how many trades each combination of periods produces, how the crossing of indicator signals behaves in a sideways market, and what share of entries comes from false breakouts.

What cannot be measured cannot be improved: manual management is verified only by the actual account, and by then there is nothing left to fix.

Automation loses where context is needed. The bot will keep looking for crossings in a thin order book, immediately after news, and on an instrument where the indicator has lost meaning; a human recognizes such regimes and simply does not trade.

Bots on other indicators — RSI, moving averages, level breakouts — are built the same way, so signal crossing is used not as “more signals — more entries” but as a filter: MACD sets the direction, the second indicator confirms the regime, and volatility cuts off the entry.

Technical questions before development starts

Before development starts, we remove engineering doubts — the ones that usually surface on a live account, when reworking the logic costs the most.

Below are answers to the questions clients ask most often, so you understand how a MACD bot is built even before we write the first line of trading logic.

How does the bot survive sharp market moves?

MACD signals lag on outliers and produce false crossings.

Therefore, we build a volatility filter into the logic: the averaging period and entry threshold are selected so that noise signals are cut off, and position size is calculated from the current price spread, not as a fixed lot.

Additionally, we limit the number of simultaneous entries and set a stop that cannot be moved manually during a drawdown.

How do you test the strategy before the real market?

First, a backtest — on quotes accounting for commission, slippage, and real order book depth, otherwise the paper result will not match live trading. Then the strategy goes to a test account with the same parameters and stays there until statistics are collected.

We look at the share of profitable trades, maximum drawdown, and average position holding time; if the discrepancy between history and the test account exceeds the agreed threshold, that version does not go into operation.

What account access is needed?

Keys are created with trading-only permissions, without withdrawal rights. We do not request access to email or payment data and do not store keys in plain text — they are kept in secure storage and inserted at launch time.

You can revoke the key on the exchange side at any time; after that, the bot simply stops trading and does not lose trade history.

What happens after bot handover?

We hand over the source code, configurations, and deployment instructions, plus a recorded walkthrough of the logic — so parameters can be changed without us.

After launch, we stay in touch: we review the trade journal, refine settings for the changed market, and explain the cause of every failure. Strategy improvements are documented as separate tasks so it is clear what was changed and why.

Let's discuss the task: inputs and work plan

An estimate for a MACD bot rests not on code but on the inputs: without them, any estimate is a guess. Therefore, we start with breaking down the trading task — we fix the hypothesis, instruments, and risk boundaries, and only then assemble the solution scheme and scope of work.

What is needed from the client:

  • Hypothesis and market: which pairs and exchanges are of interest, spot or futures market, whether short positions are needed.
  • Signal logic: timeframe and MACD parameters, entry and exit rules, filters against false crossings.
  • Risk profile: position size, maximum drawdown, daily trade limit, and bot behavior during a connection loss.
  • Access: exchange account, test keys with limited permissions, where to host the bot — in your infrastructure or ours.
  • Data: manual trading logs, prior work, trade history — we use them to build the strategy backtest.
  • Control: notification channels, set of metrics, whether manual intervention is needed, and emergency stop of the strategy.

Then the order is as follows. We break down the hypothesis and test it on history: if the expected result is not confirmed, we say so before development, not after.

Then we show the solution scheme, agree on timelines and stage composition — each stage is accepted separately, so you see the result before moving to the next.