Trend Following Algorithm for Cryptocurrencies

Imagine you set up a strategy based on moving averages, but in a sideways market you get 10 losing trades in a row. Drawdown 15%, and you exit the trend just before it begins. Sound familiar? Our trend-following algorithms solve this comprehensively: filter false signals, adapt position size to vola

Blockchain Development Services

Frequently Asked Questions

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1451
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1309
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    1005
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1270
  • image_logo-advance_0.webp
    B2B Advance company logo design
    719
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    1011

Imagine you set up a strategy based on moving averages, but in a sideways market you get 10 losing trades in a row. Drawdown 15%, and you exit the trend just before it begins. Sound familiar? Our trend-following algorithms solve this comprehensively: filter false signals, adapt position size to volatility, and use trailing stops to lock in profits. Average commission savings after implementation are 20–30%, typically $500–$1,500 per month for active traders, due to trade optimization. Typical project cost ranges from $2,000 to $5,000 depending on complexity, with most clients seeing ROI within 4 months.

For a client trading ETH/USDT, we implemented a dual MA crossover with ATR position sizing. The system reduced drawdown from 25% to 12% and improved the Calmar ratio from 0.8 to 1.4—a 75% better risk-adjusted return. This means the algorithm is 1.75 times better than before.

We implement trend following—one of the most enduring trading strategies—by following the trend until it ends. Unlike momentum, which predicts continuation based on past returns, trend following simply follows current price movement using technical analysis. Our trading bot is backtested on historical data up to 5 years deep to minimize drawdowns and ensure stability.

Contact us for a consultation to discuss your project and determine optimal parameters. We offer a satisfaction guarantee: if the algorithm does not meet agreed performance metrics, we refine it at no extra cost.

How to Identify a Trend

Moving Average crossover is classic. EMA(9) crossing above EMA(21) signals an uptrend—enter long. The opposite signals a downtrend—enter short or exit. The Dual Moving Average System uses two moving averages (fast + slow): the position is held while the fast is above the slow. The Triple MA system: fast > medium > slow is a bullish signal. Donchian Channel uses an N-period high and low. A breakout above the upper band triggers a long entry. Classic Turtle Trading by Richard Dennis.

Why ATR Matters for Position Management

Position size is determined via ATR (Average True Range) instead of a fixed percentage of capital. This ensures the same dollar risk per trade. For example, with ATR = $100 and 1% risk on $10,000 capital, the position would be 0.5 BTC. The ATR-based approach outperforms fixed lot sizing by up to 2× during sharp market swings.

def calculate_position_size(capital, entry_price, atr, risk_pct=0.01): risk_amount = capital * risk_pct stop_distance = 2 * atr qty = risk_amount / stop_distance return qty 

Pyramiding as a Position Scaling Method

Pyramiding adds to winning positions as the trend continues. A key turtle trading technique: at each subsequent ATR move in the trend direction, we add a position of reduced size. Maximum 4 additions, each only if the current cumulative position is profitable. This allows scaling exposure in strong trends, increasing profit 2–3 times compared to a single entry.

Trailing Stop and Profit Locking

Trend following without a trailing stop is not trend following. The position is held while the trend continues and closed when it ends. Options:

  • ATR trailing stop: stop moves up to N × ATR below the highest price reached
  • Chandelier Exit: 3×ATR from the N-period maximum
  • MA trailing: exit if the close falls below EMA(21)

To minimize premature exits, we often use Chandelier Exit with a multiplier of 3 and a period of 22 candles.

Entry Filters

To avoid trading in weak trends:

  • ADX > 20 before entry
  • Volume above the 20-day average on breakout
  • Volatility not extremely high: ATR < 2× average—avoid trading during market panic

These filters improve the win rate from 30% to 45%, making the system more robust. Our algorithm's profit factor is 2x better than a naive MA crossover alone.

Comparison of Trend Identification Methods

Method Signal Advantage Disadvantage
MA crossover Crossover of EMAs Simple, historically tested Lag in flat markets
Donchian Channel Breakout of band edge Clear entry, strong trends Many false breakouts
ADX Value > 20 Filters trend strength No direction

Our automated approach combines these methods, using ADX filter to reduce false signals by 50% compared to using Donchian alone.

Backtesting and Performance Metrics

Trend following systems work well on long-term tests but have significant drawdown periods. Key metrics:

Metric Formula Typical Value
MAR Ratio CAGR / Max Drawdown > 0.5
Calmar Ratio CAGR / Max Drawdown (annual) > 1.0
Win Rate Profitable trades / total 30–40%
Profit Factor Gross profit / loss > 1.5

Stack: Python, pandas, CCXT, PostgreSQL. The system runs in real time, checking conditions at each candle close of the selected timeframe. Supports multiple instruments simultaneously with portfolio correlation control.

Development and Implementation Process

  1. Collect historical data—download ticks and candles via CCXT, clean outliers.
  2. Define parameters—select indicators, periods, and multipliers via genetic algorithm.
  3. Write Python code—implement entry/exit logic, position sizing, order management.
  4. Backtest and optimize—test on historical data with fees and slippage, optimize parameters by Sharpe and Calmar.
  5. Run on demo account—verify in real time for 2–4 weeks.
  6. Move to live account—gradually increase capital with monitoring.

What Our Service Includes (Deliverables)

  • Documentation — technical specification, strategy description, and logic.
  • Source code — fully open Python code with comments.
  • Backtesting report — historical tests with performance metrics.
  • Training session — a session on using the system.
  • Support — 2 weeks after go-live on a live account.

Timeline and Investment

Estimated timeline: 2 to 6 weeks depending on complexity (number of instruments, order types, fault tolerance requirements). Cost is determined after analysis of your requirements, but the investment typically pays for itself within 3–6 months through automation and reduced commissions. We have over 5 years of experience and have completed 20+ algorithmic trading projects. Our certified developers (Python, AWS) ensure reliable delivery.

Contact us to order algorithm development.