Dual Moving Average Chasing Strategy
This is a moving average based chasing strategy. It utilizes the direction of moving averages and candle shadows to determine price trends and momentum for entries and exits. The core logic is to go long/short when…

Overview
This is a moving average based chasing strategy. It utilizes the direction of moving averages and candle shadows to determine price trends and momentum for entries and exits. The core logic is to go long/short when the color of the second moving average changes, and use strong signals from the third moving average to add positions, up to 5 additions.
Strategy Principle
The strategy uses Heikin Ashi moving averages to determine trends. Specifically, the strategy defines 3 moving averages:
- The second moving average is used to determine trend reversal. Enter trades when its color changes.
- The third moving average is used to identify strong breakout signals for adding positions.
Entry Logic:
- When the second moving average color changes from red to green, go long.
- If the third moving average now shows a strong uptrend signal (green candle with no lower shadow), add position.
- Allow up to 5 additions.
Exit Logic:
- When either moving average color changes, close all positions.
Advantage Analysis
The advantages of this strategy:
- Heikin Ashi reduces noise for better signals.
- Dual moving averages combo improves entry timing accuracy.
- Adding positions to chase trends allows bigger profit.
Risk Analysis
There are also some risks:
- Dual moving average crossovers can cause whipsaws.
- Over-adding may increase losses.
- Parameters need tuning for different products and timeframes.
Risks can be managed via stop loss, reducing additions, and parameter optimization.
Optimization Directions
The strategy can be improved in the following aspects:
- Test different parameter sets for the moving averages.
- Optimize stop loss methods like trailing stop loss.
- Test parameters separately for different products.
- Add filters to prevent adding too fast.
- Incorporate other indicators for entry timing.
Summary
In summary, this is a trend chasing strategy based on dual moving average directionality. It combines the advantage of trend and momentum analysis for expanded profits from adding positions. But risks need to be managed via stop loss and parameter tuning. Further improvements can be made in optimizing stops, tuning parameters etc.
Source Pine Script
/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("Average K Script Trading Strategy", overlay=true)
// Definition Heikin Ashi Indicator
ha_open = security(heikinashi(syminfo.tickerid), "60", open)
ha_high = security(heikinashi(syminfo.tickerid), "60", high)
ha_low = security(heikinashi(syminfo.tickerid), "60", low)
ha_close = security(heikinashi(syminfo.tickerid), "60", close)
// Confirm Heikin Ashi Indicator color
isGreen = ha_open < ha_close
// Define additional purchase times
var int add_on_buy = 10
var int add_on_sell = 10
// Define Entry and Exit Conditions
long_condition = crossover(ha_close, ha_open) and isGreen and ha_low == ha_open
short_condition = crossunder(ha_close, ha_open) and not isGreen and ha_high == ha_open
exit_condition = crossover(ha_open, ha_close) or crossunder(ha_open, ha_close)
// If conditions are met, perform entry and exit operations
if (long_condition)
strategy.entry("Buy", strategy.long)
if (short_condition)
strategy.entry("Sell", strategy.short)
if (exit_condition)
strategy.close("Buy")
strategy.close("Sell")
// Draw Heikin Ashi Candlestick chart
plotcandle(iff(ha_open < ha_close, ha_open, na), ha_high, ha_low, ha_close, title='Green Candles', color=#53b987, wickcolor=#53b987, bordercolor=#53b987)
plotcandle(iff(ha_open >= ha_close, ha_open, na), ha_high, ha_low, ha_close, title='Red Candles', color=#eb4d5c, wickcolor=#eb4d5c, bordercolor=#eb4d5c)
Published by ChaoZhang on the FMZ strategy square · last modified 2024-02-20. 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/Dual-Moving-Average-Chasing-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
- Dynamic ATR based Trailing Stop Trading StrategyPine Script · Breakout · 1d
- Kana Candle Breakout Strategy Based on Moving Average and Support ResistancePine Script · Breakout · 1h
- Momentum Breakout Trading Strategy 440964Pine Script · Breakout · 5m
- Moving Average Bollinger Bands Breakout StrategyPine Script · Breakout · 1h
- Multi Indicator Momentum Breakout with Smoothed Candlestick Trading StrategyPine Script · Breakout · 6h
- Quantitative Trading Strategy Based on Ichimoku with Multiple SignalsPine Script · Breakout · 1h