0bps

Strategy vault / Trend following

SMA Crossover Trading Strategy

SMA Crossover Trading Strategy This strategy generates trading signals based on crossover between two SMA lines of different periods. A long signal is triggered when the faster SMA crosses above the slower SMA. A…

Author
ChaoZhang
Complexity
Starter · 23 lines
Parameters
0
Backtest bar
10m · intraday
Tested on
BTC/USDT · futures

SMA Crossover Trading Strategy

This strategy generates trading signals based on crossover between two SMA lines of different periods. A long signal is triggered when the faster SMA crosses above the slower SMA. A short signal occurs when the faster SMA crosses below the slower SMA.

Some key benefits of this strategy:

  • Identifies trend changes using SMA crossovers
  • Simple and straightforward rules
  • Customizable SMA periods for optimization
  • Applicable for any timeframe

However, some potential limitations exist:

  • Prone to false signals during range-bound markets
  • Lagging signals, late entry timing
  • No stop loss, can lead to large drawdowns
  • Lack of filters, uncontrolled signal quality

Some ways to enhance the strategy:

  • Add stop loss when price touches slower SMA
  • Scale in based on bull/bear candle closes
  • Optimize SMA period combinations
  • Adjust position sizing and risk management

Overall, the SMA crossover method works well in trending markets but must be traded cautiously during choppy periods. Incorporating stop loss and proper risk management can reduce downside risks.

Source Pine Script

/*backtest
start: 2023-08-11 00:00:00
end: 2023-09-10 00:00:00
period: 10m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
strategy("SMA Crossover demo", overlay=true)

shortCondition = crossover(sma(close, 34), sma(close, 4))
if (shortCondition)
    strategy.entry("Sell/Short", strategy.short)

longCondition = crossunder(sma(close, 34), sma(close, 4))
if (longCondition)
    strategy.entry("Buy/Long", strategy.long)
    



    

Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-11. 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/SMA-Crossover-Trading-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