0bps

Strategy vault / Trend following

1 Profit Moving Average Cross Strategy

This strategy generates buy signals when a fast moving average (Fast MA) crosses above a slow moving average (Slow MA). It also takes profit when the returns reach 1% to lock in small but consistent profits. The…

Author
ChaoZhang
Complexity
Starter · 41 lines
Parameters
3
Backtest bar
3d · position
Tested on
BTC/USDT · futures

IMG

Overview

This strategy generates buy signals when a fast moving average (Fast MA) crosses above a slow moving average (Slow MA).

It also takes profit when the returns reach 1% to lock in small but consistent profits.

The strategy works well in trending markets with clear trends. It can capture medium-term up trends and achieve steady profits.

Strategy Logic

The strategy is based on the golden cross of moving averages. Moving averages reflect the medium-term trend of stock prices. When the short-term MA crosses above the longer-term MA, it signals that the short-term upward momentum is stronger than the long-term trend. This is a strong buy signal.

The fast MA in this strategy has a length of 10 days and the slow MA is 30 days. This can capture reasonable trend movements. A long signal is triggered when the fast MA crosses above the slow MA.

The strategy also sets a 1% take profit point. Positions will be closed when the returns hit 1% to lock in profits. This helps avoid losses from trend reversals.

Strength Analysis

The strengths of this strategy are:

  1. Simple to understand and implement with moving average indicators.
  2. Fast and slow MA combo effective at identifying medium-term trends.
  3. 1% profit target controls risks and locks in consistent gains.

Overall the strategy is quite robust and can achieve steady profits in trending markets.

Risk Analysis

There are also some risks to consider:

  1. More whipsaws and stop loss triggers in range-bound markets without clear trends.
  2. Ineffective in complex non-trending markets.
  3. No stop loss so vulnerable to huge sudden losses in volatile markets.

To address these risks:

  1. Add other indicators like Bollinger Bands, KDJ for better signal accuracy.
  2. Dynamically adjust MA parameters to adapt to changing market conditions.
  3. Add reasonable stop loss points to control downside on losing trades.

Optimization Opportunities

Some ways to optimize this strategy:

  1. Test more fast and slow MA parameter combinations to find optimal settings.
  2. Add stop loss. For example, cut loss when trade drops 3%.
  3. Combine with other indicators like MACD, KDJ to form multifactor models and improve signal accuracy.
  4. Utilize auto-optimization methods to find the best parameter combinations.

Conclusion

The strategy is a typical moving average crossover system. It identifies medium-term trends using fast and slow MA, taking 1% profit along the way. Strengths include simplicity and the ability to ride uptrends for steady gains. Weakness is poorer adaptation to complex, volatile markets. By optimizing with more indicators and stop loss mechanisms, the strategy can achieve more robust performance.

Parameters

NameDefaultWhat it controls
v_input_110Fast MA Length
v_input_230Slow MA Length
v_input_3trueProfit Percentage

Source Pine Script

/*backtest
start: 2023-01-01 00:00:00
end: 2023-06-15 00:00:00
period: 3d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © pleasantHead5366

//@version=4
strategy("1% Profit Strategy", overlay=true)

// Input parameters
fastLength = input(10, title="Fast MA Length")
slowLength = input(30, title="Slow MA Length")
profitPercentage = input(1, title="Profit Percentage")

// Calculate moving averages
fastMA = sma(close, fastLength)
slowMA = sma(close, slowLength)

// Plot moving averages on the chart
plot(fastMA, color=color.blue, title="Fast MA")
plot(slowMA, color=color.red, title="Slow MA")

// Trading logic
longCondition = crossover(fastMA, slowMA)
if (longCondition)
    strategy.entry("Buy", strategy.long)

// Close long position when profit reaches 1%
if (strategy.position_size > 0)
    strategy.exit("Take Profit", from_entry="Buy", profit=profitPercentage / 100)

// Plot Buy and Sell signals on the chart
shortCondition = crossunder(fastMA, slowMA)
if (shortCondition)
    strategy.entry("Sell", strategy.short)

Published by ChaoZhang on the FMZ strategy square · last modified 2023-12-06. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/1-Profit-Moving-Average-Cross-Strategy.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open