0bps

Strategy vault / Other

Triple EMA MACD

long 50 200 ema short 50<200 ema tyvm have a nice day backtest

Pine ScriptOtherMACDEMA
Author
ChaoZhang
Complexity
Intermediate · 58 lines
Parameters
11
Backtest bar
30m · intraday
Tested on
BTC/USDT · futures

long 50>200 ema short 50<200 ema

tyvm have a nice day

backtest

IMG

Parameters

NameDefaultWhat it controls
v_input_1trueEnable 2nd MA
v_input_2trueEnable 3rd MA
v_input_350First length
v_input_4150Second length
v_input_5200Third length
v_input_6_close0First source: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4
v_input_7_close0Second source: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4
v_input_8_close0Third source: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4
v_input_926fastLength
v_input_1049slowlength
v_input_112MACDLength

Source Pine Script

/*backtest
start: 2022-04-10 00:00:00
end: 2022-05-03 23:59:00
period: 30m
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
//@Author: AdventTrading
//Modified by viraltaco_

// This indicator was made to allow three moving averages to be displayed 
// without needing to use up 3 charting indicators individually

strategy(title = "Triple EMA + MACD", shorttitle = "tEMACd", overlay = true, default_qty_value = 750)

// Checkbox's for the other 2 MA's
line_2 = input(true, title = "Enable 2nd MA")
line_3 = input(true, title = "Enable 3rd MA")

len_1 = input( 50, minval = 1, title = "First length")
len_2 = input(150, minval = 1, title = "Second length")
len_3 = input(200, minval = 1, title = "Third length")

src_1 = input(close, title = "First source")
src_2 = input(close, title = "Second source")
src_3 = input(close, title = "Third source") 

tit_1 = "EMA 50"
tit_2 = "EMA 150"
tit_3 = "EMA 200"

plot(ema(src_1, len_1), title = tit_1, color = #10aaff)
plot((line_2) ? ema(src_2, len_2) : na, title = tit_2, color = #10ad00)
plot((line_3) ? ema(src_3, len_3) : na, title = tit_3, color = #ad0010)

//strategy("MACD Strategy", overlay=true)

fastLength = input(26)
slowlength = input(49)
MACDLength = input(2)

SMema = ema(src_1, len_1)
LGema = ema(src_3, len_3)
MACD = ema(close, fastLength) - ema(close, slowlength)
aMACD = ema(MACD, MACDLength)
delta = MACD - aMACD


if (crossover(delta, 0) and SMema > LGema)
    strategy.entry("MacdLE", strategy.long, comment="MacdLE")


if (crossunder(delta, 0) and SMema < LGema)
    strategy.entry("MacdSE", strategy.short, comment="MacdSE")

//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)

Published by ChaoZhang on the FMZ strategy square · last modified 2022-05-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/Triple-EMA-MACD.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