0bps

Strategy vault / Breakout

Dual Moving Average Breakout Strategy

This strategy uses both SMA and EMA moving averages to determine long and short direction based on price breakouts. It goes long when the close is above both SMA and EMA, goes short when the close is below both SMA…

Author
ChaoZhang
Complexity
Intermediate · 44 lines
Parameters
7
Backtest bar
10m · intraday
Tested on
BTC/USDT · futures

This strategy uses both SMA and EMA moving averages to determine long and short direction based on price breakouts. It goes long when the close is above both SMA and EMA, goes short when the close is below both SMA and EMA, and flattens out when the close is between the SMA and EMA. The SMA and EMA periods can be customized by the user.

The advantage of this dual moving average breakout strategy is combining two moving average systems can improve accuracy. However, issues like false signals during range-bound markets and lagging signals exist. Also, no stop loss is implemented to control losses.

In summary, this strategy works better when strong trends are present, but should be traded cautiously. Optimization of parameters, adding stops, and extra filters can improve the strategy by reducing false signals.

Overall, the dual moving average breakout strategy has a simple trading logic, but requires proper risk control and parameter tuning to be applied successfully in live trading.

Parameters

NameDefaultWhat it controls
v_input_1truelong
v_input_2trueshort
v_input_3trueUse MA1 (SMA, blue)
v_input_4trueUse MA2 (EMA, red)
v_input_540MA1 length
v_input_640MA2 length
v_input_7trueUse color-filter

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=2
strategy(title = "Noro's Multima v1.0", shorttitle = "Multima 1.0", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value=100.0, pyramiding=0)

needlong = input(true, "long")
needshort = input(true, "short")

usema1 = input(true, "Use MA1 (SMA, blue)")
usema2 = input(true, "Use MA2 (EMA, red)")
lenma1 = input(40, defval = 40, minval = 2, maxval = 1000, title = "MA1 length")
lenma2 = input(40, defval = 40, minval = 2, maxval = 1000, title = "MA2 length")
//anti = input(true, defval = true, title = "Antipila")
usecf = input(true, defval = true, title = "Use color-filter")

//Strategy
ma1 = sma(close, lenma1)
ma2 = ema(close, lenma2)
signal1 = usema1 == false ? 0 : close > ma1 ? 1 : -1
signal2 = usema2 == false ? 0 : close > ma2 ? 1 : -1
lots = signal1 + signal2

//Lines
plot(ma1, color = blue, linewidth = 3, transp = 0)
plot(ma2, color = red, linewidth = 3, transp = 0)

//Trading
if lots > 0 and (close < open or usecf == false)
    strategy.entry("Long", strategy.long, needlong == false ? 0 : na)

if lots < 0 and (close > open or usecf == false)
    strategy.entry("Short", strategy.short, needshort == false ? 0 : na)
    
if lots == 0
    strategy.close_all()
    
    
    

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/Dual-Moving-Average-Breakout-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