Strategy vault / Trend following
Short term Down Trend Strategy Based on EMA and Adaptive Fibonacci Retracement
This strategy uses EMA to determine trend direction and adaptive Fibonacci retracement to automatically identify reversal points, aiming to sell high and buy low by catching down trends. It involves frequent trading…
Overview
This strategy uses EMA to determine trend direction and adaptive Fibonacci retracement to automatically identify reversal points, aiming to sell high and buy low by catching down trends. It involves frequent trading suitable for short-term trading.
Strategy Logic
Use 9-day EMA and 21-day EMA golden cross and death cross to determine trend direction. 21-day EMA crossing below 55-day EMA signals a down trend start.
Implement adaptive Fibonacci retracement with 100 periods to automatically determine key retracement levels based on recent price swings.
Price breaking 0.236 Fibonacci retracement indicates a reversal and closes existing position.
When 9-day EMA crosses below 21-day EMA, and price is lower than adaptive Fibonacci high, go short.
Long profit target is a crossover above 200-day EMA. Short stop loss is breaking 0.236 Fibonacci retracement.
Advantages
EMA gives clear trend signals, easy to implement
Adaptive Fibonacci avoids manual parameter tuning
Frequent trading catches short-term moves for high frequency strategies
Key retracement levels for timely stop loss
Configurable parameters for optimization across cycles
Risks
EMA lagging requires confirmation from other indicators
Adaptive Fibonacci risks overfitting with unstable levels
High frequency trading increases costs from commissions and slippage
Ineffective filtering of range-bound trends leads to false signals
Needs improvement in drawdown management and risk-reward control
Enhancement
Add volume indicators to avoid false signals from price-volume divergence
Optimize EMA periods to better fit current market conditions
Implement dynamic stop loss for better risk control
Incorporate trend strength index to avoid whipsaws
Consider trading costs impact and set minimum profit target
Conclusion
This strategy identifies trend direction with EMA and determines reversal levels dynamically using adaptive Fibonacci retracement, which automatically adapts to different market conditions. But it relies more on indicator cues without trend segmentation and Elliott Wave logic, leaving room for optimization. Overall, as a high frequency short-term trading strategy, it can capture fast price changes but involves risks of frequent stop loss and overtrading that traders need to manage.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_int_1 | 100 | (?Automatic Fibonacci Retracement)Fibonacci Length |
| v_input_int_2 | true | Show Last |
| v_input_int_3 | 5 | Offset Length |
Source Pine Script
/*backtest
start: 2023-08-21 00:00:00
end: 2023-09-20 00:00:00
period: 1h
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/
// © CheatCode1
//@version=5
strategy("CC-Trend strategy 2", overlay=true, initial_capital = 10000, commission_type = strategy.commission.percent, commission_value = 0.01, default_qty_type = strategy.percent_of_equity, default_qty_value = 100 )
ema9 = ta.ema(close, 9)
ema21 = ta.ema(close, 21)
ema55 = ta.ema(close, 55)
ema200 = ta.ema(close, 200)
plot(ema200, '22', color.blue, 2)
FibL = input.int(100, 'Fibonacci Length', 1, 500, group = 'Automatic Fibonacci Retracement')
len1 = input.int(1, 'Show Last', 0, 1000, group = 'Automatic Fibonacci Retracement')
len2 = input.int(5, 'Offset Length', 0, 1000, group = 'Automatic Fibonacci Retracement')
highF = ta.highest(ema55 >= ema9 ? ema55:ema9, FibL)
lowF = ta.lowest(ema55 >= ema9 ? ema9:ema55, FibL)
AvgFib = highF - lowF
//Fibonacci Executions
LL2 = highF + .618 * AvgFib
LL1 = highF + .272 * AvgFib
L1 = highF
L236 = highF - 0.236 * AvgFib
L382 = highF - 0.382 * AvgFib
Mid = highF - 0.50 * AvgFib
S382 = lowF + 0.382 * AvgFib
S236 = lowF + 0.236 * AvgFib
S1 = lowF
SS1 = lowF - .272 * AvgFib
SS2 = lowF - .618 * AvgFib
//Fibonacci Plot's
high2FP = plot(LL2, 'Highe2', color.red,offset = len2, show_last = len1, trackprice = true)
high1FP = plot(LL1, 'Highe1', color.red,offset = len2, show_last = len1, trackprice = true)
highFP = plot(highF, 'High', color.red,offset = len2, show_last = len1, trackprice = true)
L236P = plot(L236, "0.764", #ED381C, offset = len2, show_last = len1, trackprice = true )
L382P = plot(L382, "0.618", color.white,offset = len2, show_last = len1, trackprice = true )
MidP = plot(Mid, "0.5", color.orange,offset = len2, show_last = len1, trackprice = true )
S382P = plot(S382, "0.382", color.yellow ,offset = len2, show_last = len1, trackprice = true)
S236P = plot(S236, "0.236", color.lime ,offset = len2, show_last = len1, trackprice = true)
lowFP = plot(lowF, 'Low', color.green,offset = len2, show_last = len1, trackprice = true)
low1FP = plot(SS1, 'Lowe1', color.green,offset = len2, show_last = len1, trackprice = true)
low2FP = plot(SS2, 'Lowe2', color.green,offset = len2, show_last = len1, trackprice = true)
plot(ema9, '22', color.yellow, 2)
plot(ema55, '55', color.aqua, 2)
plot(ema200, '200', color.maroon, 2)
shortCondition = close[1] < highF and ema21 < ema55
if (shortCondition)
strategy.entry("Short", strategy.short)
shorttp = ta.crossover(close, ema200) and strategy.openprofit >= 0
if (shorttp)
strategy.close('Short', 'Short TP', qty_percent = 100)
shortclose2 = close[1] > L236 and not (shortCondition)
if(shortclose2)
strategy.close('Short', 'Short RM', qty_percent = 100)Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-21. 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/Short-term-Down-Trend-Strategy-Based-on-EMA-and-Adaptive-Fibonacci-Retracement.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
- Incremental Order Size Fibonacci Retracement Trend Following StrategyPine Script · Trend following · 1d
- Multi EMA Crossover with Fibonacci Extension Trend Following StrategyPine Script · Trend following · 3h
- Fibonacci Moving Averages Input StrategyPine Script · Trend following · 1d
- Multi Period Trend Confirmation Dynamic Risk Control Quantitative Trading StrategyPine Script · Trend following · 1h
- Trend Following Trading Strategy Based on Granville and MACD Multiple Signal ConfirmationPine Script · Trend following · 1d
- Elliott Wave and Tom DeMark Trend Following Trading StrategyPine Script · Trend following · 1m