Moving Average Buy Sell
Takes two moving averages of different lengths to formulate buy/sell colors on average EMA . backtest
Takes two moving averages of different lengths to formulate buy/sell colors on average EMA .
backtest

Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1_close | 0 | Source: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4 |
| v_input_int_1 | 20 | Length Wave |
| v_input_2_close | 0 | Source: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4 |
| v_input_int_2 | 200 | Length Tide |
Source Pine Script
/*backtest
start: 2021-05-08 00:00:00
end: 2022-05-07 23:59:00
period: 4h
basePeriod: 15m
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/
// © dannhau2
//@version=5
indicator(title="Moving Average Buy-Sell", shorttitle="MABS", overlay=true, timeframe="", timeframe_gaps=true)
Wave = ta.ema(input(close, title="Source"), input.int(20, minval=1, title="Length Wave"))
Tide = ta.ema(input(close, title="Source"), input.int(200, minval=1, title="Length Tide"))
AVG = (Wave + Tide)/2
Up = ta.crossover(Wave, Tide)
Down = ta.crossover(Tide,Wave)
var col = color.red
if Up
col := color.lime
if Down
col := color.red
P1=plot(AVG, title="MABS", color=col, linewidth = 3, display=display.none)
P2=plot(Wave, title="MA-Wave", color=col, linewidth = 2)
P3=plot(Tide, title="MA-Tide", color=col, linewidth = 3)
fill(P2, P3, color= Wave > Tide ? color.new(color.lime,70):color.new(color.red, 70))
alertcondition(Up, title="Trend Changed Positive", message="Trend Changed Positive")
alertcondition(Down, title="Trend Changed Negative", message="Trend Changed Negative")
if Up
strategy.entry("Enter Long", strategy.long)
else if Down
strategy.entry("Enter Short", strategy.short)Published by ChaoZhang on the FMZ strategy square · last modified 2022-05-09. 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/Moving-Average-Buy-Sell.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.