Strategy vault / Trend following
11Trend SMA Trading Strategy 11
This is a trading strategy that uses only two Simple Moving Average lines (SMA). It utilizes a slow SMA line to define the trend direction and a fast SMA line to determine specific entry points. The strategy is…
Overview
This is a trading strategy that uses only two Simple Moving Average lines (SMA). It utilizes a slow SMA line to define the trend direction and a fast SMA line to determine specific entry points. The strategy is suitable for cryptocurrency trading at hourly and higher timeframes.
Strategy Logic
The strategy judges the trend direction by calculating the fast and slow SMA lines. Specifically:
The slow SMA line (blue) is used to define the trend direction. A downtrend is defined when the price is below the slow SMA, and an uptrend when the price is above it.
The fast SMA line (red) is used to determine specific entry points. In an uptrend, go long when the candlestick close is lower than the open and below the fast SMA. In a downtrend, go short when the close is higher than the open and above the fast SMA.
The strategy also considers the candlestick color, only taking trades in the direction of the defined trend - long signals in uptrends and short signals in downtrends, avoiding countertrend trades.
Advantages
- The strategy uses only two basic SMA indicators, very simple to understand.
- Using two SMA lines to determine trends is reliable, avoiding market noise.
- Considering candlestick color avoids countertrend entries, reducing risk.
- Customizable fast and slow SMA parameters suit different market conditions.
- Can go only long or short, flexible for different market situations.
Risk Analysis
- SMA has lagging characteristics, may miss trend turning points.
- Fixed parameters cannot adapt to changing markets, need adjustment.
- Trend judgment may be wrong, leading to countertrend trade risks.
- Lack of confirmation with single indicator combo, overtrading risk.
Possible optimizations to address the risks:
Add MACD to confirm trend.
Implement stop loss to control risk.
Add parameter optimization for adaptive parameters.
Add entry confirmation to avoid overtrading.
Optimization Directions
The main aspects to optimize the strategy:
Parameter optimization. Add module for automatic parameter adjustment based on market conditions.
Entry confirmation. Add indicators like MACD, Bollinger Bands to confirm SMA signals.
Stop loss. Implement stop loss strategies like trailing stop loss to limit risks.
Drawdown control. Close all positions when max drawdown percentage is reached to limit losses.
Cross timeframe validation. Use higher timeframe indicators to confirm lower timeframe SMA signals.
Long/short selection. Add switches to select only long or short trades for different markets.
Summary
The strategy has clear, easy-to-understand logic using simple trend-following indicators. But it has limited profit potential and inadequate risk control. Next steps are to optimize parameters and risk management for better market adaptability and effective risk control, further improving the strategy.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 5 | fast SMA Period |
| v_input_2 | 15 | slow SMA Period |
| v_input_3 | false | Only long? |
Source Pine Script
/*backtest
start: 2023-08-22 00:00:00
end: 2023-09-21 00:00:00
period: 4h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
strategy("Noro's Trend SMA Strategy v1.1", shorttitle = "Trend SMA str 1.1", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value=100.0, pyramiding=0)
fastlen = input(5, "fast SMA Period")
slowlen = input(15, "slow SMA Period")
only = input(false, "Only long?")
fastsma = ema(close, fastlen)
slowsma = ema(close, slowlen)
trend = low > slowsma ? 1 : high < slowsma ? -1 : trend[1]
up = trend == 1 and low < fastsma and close < open ? 1 : 0
dn = trend == -1 and high > fastsma and close > open ? 1 : 0
plot(fastsma, color = red, title = "Fast SMA")
plot(slowsma, color = blue, title = "Slow SMA")
longCondition = up == 1
if (longCondition)
strategy.entry("Long", strategy.long)
shortCondition = dn == 1
if (shortCondition)
strategy.entry("Short", strategy.short, only == true ? 0 : na)Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-22. 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.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/11Trend-SMA-Trading-Strategy-11.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- 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
- Bollinger Bands and RSI Trend Following StrategyPine Script · Trend following · 1h
- EMA and RSI Trend Trading StrategyPine Script · Trend following · 1d
- Multi Indicator Trend Following Strategy with Dynamic Risk ManagementPine Script · Trend following · 2h
- Trend Following Strategy Based on EMA and SMA CrossoverPine Script · Trend following · 1h
- Dynamic Moving Average Crossover Combo StrategyPine Script · Trend following · 10m
- Dynamic Moving Average Trend Crossover StrategyPine Script · Trend following · 1d