Strategy vault / Trend following
ATR and T3 Moving Average Strategy
This strategy combines ATR and T3 moving average for trend determination and tracking. ATR forms price channels to judge overall trend direction. T3 moving average gives entry signals and stop loss exit points. The…
Overview
This strategy combines ATR and T3 moving average for trend determination and tracking. ATR forms price channels to judge overall trend direction. T3 moving average gives entry signals and stop loss exit points. The strategy suits trend followers seeking steady profits.
Strategy Logic
ATR forms price channels, channel direction determines main trend.
T3 moving average helps determine specific entry timing, buying on price breaking T3 line.
Price breaking below lower band triggers stop loss exit; breaking above upper band takes profit.
Options for long-only or dual directional trading.
Parameter optimization combined with indicator nature to find optimal settings.
Advantage Analysis
ATR channels give clear trend identification and direction.
Adjustable T3 parameters for capturing trends on different levels.
Consistent stop loss and take profit rules avoid arbitrary exits.
Low trade frequency suits long-term holding strategies.
Risk Analysis
Indicator divergence can cause wrong trades.
Not considering individual stock volatility patterns risks overfitting.
Low trade frequency risks missing opportunities and limited profit potential.
Heavy position holding brings end-of-day slippage risks.
Optimization Directions
Add other indicators to ensure trade validity.
Parameter tuning for different products improves adaptability.
Optimize position sizing to balance frequency and risk.
Consider dynamic trailing stop loss and profit taking to expand profit room.
Add strategy-level FILTERS to improve robustness.
Summary
The strategy integrates ATR and T3 moving average for simple and effective trend tracking. But further enhancements in indicator logic and parameter optimization can lower errors and make it more practical.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | false | shorts on? |
| v_input_2 | 5 | Precantage |
| v_input_3 | 25 | Lenght of T3 |
| v_input_4 | 0.72 | Volume Factor of T3 with HA source |
| v_input_5 | 5 | Factor |
| v_input_6 | 5 | Pd |
| v_input_7 | true | Factor1 |
| v_input_8 | true | Pd1 |
Source Pine Script
/*backtest
start: 2023-09-09 00:00:00
end: 2023-09-16 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
//Author - CryptoJoncis
strategy("ATR and T3 strategy", shorttitle="AT3S_CryptoJoncis", overlay=true)
shorting = input(false, title="shorts on?")
precentage_diff = input(5,title="Precantage")/100
Lengthx = input(25, title="Lenght of T3")
//For best results use 0.7 or 0.618
Vfactx = input(0.72, minval=0.01,step=0.01, title="Volume Factor of T3 with HA source")
Source_of_T3_Normal = close
Source_of_T3 = Source_of_T3_Normal
FirstEMAx = ema(Source_of_T3, Lengthx)
SecondEMAx = ema(FirstEMAx, Lengthx)
ThirdEMAx = ema(SecondEMAx, Lengthx)
FourthEMAx = ema(ThirdEMAx, Lengthx)
FifthEMAx = ema(FourthEMAx, Lengthx)
SixthEMAx = ema(FifthEMAx, Lengthx)
//Doing all the calculations which are from
c1x = -Vfactx*Vfactx*Vfactx
c2x = 3*Vfactx*Vfactx + 3*Vfactx*Vfactx*Vfactx
c3x = -6*Vfactx*Vfactx -3*Vfactx -3*Vfactx*Vfactx*Vfactx
c4x = 1 + 3*Vfactx + Vfactx*Vfactx*Vfactx + 3*Vfactx*Vfactx
//Assigning EMAS to T3 Moving average
T3MAx = c1x * SixthEMAx + c2x * FifthEMAx + c3x * FourthEMAx + c4x * ThirdEMAx
color_of_Tilson_Moving_Average = T3MAx > T3MAx[1] ? lime : red
plot(T3MAx, title="Tilson Moving Average(ema)", color=color_of_Tilson_Moving_Average)
t_up = T3MAx + (T3MAx * precentage_diff)
t_dn = T3MAx - (T3MAx * precentage_diff)
x=plot(t_up, color=color_of_Tilson_Moving_Average)
z=plot(t_dn, color=color_of_Tilson_Moving_Average)
fill(x,z, color= T3MAx[1] < T3MAx ? lime : gray)
Factor=input(5, minval=1)
Pd=input(5, minval=1)
//
Up=hl2-(Factor*atr(Pd))
Dn=hl2+(Factor*atr(Pd))
TrendUp=close[1]>TrendUp[1]? max(Up,TrendUp[1]) : Up
TrendDown=close[1]<TrendDown[1]? min(Dn,TrendDown[1]) : Dn
Trend = close > TrendDown[1] ? 1: close< TrendUp[1]? -1: nz(Trend[1],1)
Tsl = Trend==1? TrendUp: TrendDown
linecolor = Trend == 1 ? green : red
//
b=plot(Tsl, color = linecolor , style = line , linewidth = 2,title = "")
Factor1=input(1, minval=1)
Pd1=input(1, minval=1)
//
Up1=hl2-(Factor1*atr(Pd1))
Dn1=hl2+(Factor1*atr(Pd1))
TrendUp1=close[1]>TrendUp1[1]? max(Up1,TrendUp1[1]) : Up1
TrendDown1=close[1]<TrendDown1[1]? min(Dn1,TrendDown1[1]) : Dn1
Trend1 = close > TrendDown1[1] ? 1: close< TrendUp1[1]? -1: nz(Trend1[1],1)
Tsl1 = Trend1==1? TrendUp1: TrendDown1
linecolor1 = Trend1 == 1 ? green : red
//
a=plot(Tsl1, color = linecolor1 , style = line , linewidth = 2,title = "")
long = (close > Tsl and close > Tsl1 and close > T3MAx)
short = (close < Tsl and close < Tsl1 and close < T3MAx)
if(shorting==true)
strategy.entry("MacdSE", strategy.short, comment="Open Short", when=short)
strategy.entry("MacdLE", strategy.long, comment="Open Long", when=long)
strategy.close("MacdLE", when=hl2 < t_dn)
strategy.close("MacdSE", when=hl2 > t_up)
if(shorting==false)
strategy.entry("MacdLE", strategy.long, comment="Open Long", when=long)
strategy.close("MacdLE", when=hl2 < t_dn)
fill(a,b,color=linecolor)
Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-17. 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/ATR-and-T3-Moving-Average-Strategy.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
- ATR Dynamic Trend Following and EMA Crossover Trading StrategyPine Script · Trend following · 1d
- ATR and Moving Average Crossover Hybrid StrategyPine Script · Trend following · 1h
- Adaptive ATR and RSI Trend Following Strategy with Trailing Stop LossPine Script · Trend following · 1h
- Bollinger Bands and RSI Trend Following StrategyPine Script · Trend following · 1h
- Dual ATR Channel Trend Following StrategyPine Script · Trend following · 15m
- Dual EMA Filtered ATR Adaptive Trend Following StrategyPine Script · Trend following · 1h