Strategy vault / Trend following
Diamond Trend
Diamond Trend is an indicator clearly way to catch the trend in the begining $$ backtest
Diamond Trend is an indicator clearly way to catch the trend in the begining $$
backtest

Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 0.02 | start |
| v_input_2 | 0.02 | increment |
| v_input_3 | 0.2 | maximum |
| v_input_4 | 100 | len |
| v_input_5 | 1.9 | Deviation |
Source Pine Script
/*backtest
start: 2022-04-09 00:00:00
end: 2022-05-08 23:59:00
period: 15m
basePeriod: 5m
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/
// © meer2019
//@version=4
study(title="PSAR x", overlay=true)
start = input(0.02)
increment = input(0.02)
maximum = input(0.2)
c=close
psar = sar(start, increment, maximum)
cp = psar
len = input(100, minval=1),off= 0,dev= input(1.9, "Deviation")
lreg = linreg(cp, len, off), lreg_x =linreg(cp, len, off+1)
b = bar_index, s = lreg - lreg_x,intr = lreg - b*s
dS = 0.0
for i=0 to len-1
dS:= dS + pow(cp[i]-(s*(b-i)+intr), 2)
de = sqrt(dS/(len))
up = (-de*dev) + psar
down= (de*dev) + psar
up_t = 0.0
up_t := c[1] > up_t[1] ? max(up, up_t[1]) : up
down_t = 0.0
down_t := c[1] < down_t[1] ? min(down, down_t[1]) : down
trend = 0
trend := c > down_t[1] ? 1: c < up_t[1] ? -1 : nz(trend[1], 1)
//
r_line = trend ==1 ? up_t : down_t
plot(r_line)
buy=crossover( c, r_line)
sell=crossunder(c, r_line)
if buy
strategy.entry("Enter Long", strategy.long)
else if sell
strategy.entry("Enter Short", strategy.short)
Published by ChaoZhang on the FMZ strategy square · last modified 2022-05-10. 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/Diamond-Trend.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
- Dual ATR Channel Trend Following StrategyPine Script · Trend following · 15m
- PSAR and EMA Based Quantitative Trading StrategyPine Script · Trend following · 1h
- Parabolic SARPine Script · Trend following · 5m
- Double Moving Average Crossover Strategy 436797Pine Script · Trend following · 1h
- Dual Laser Trend seeking StrategyPine Script · Trend following · 1h
- Multi Timeframe Parabolic SAR Dynamic Trend Following Quantitative StrategyPine Script · Trend following · 2h