Strategy vault / Trend following
Spiral Cross Strategy with Moving Average Confirmation
This strategy combines the Vortex Indicator and Moving Average lines to identify the direction and strength of price trends in order to generate potential long and short signals. When the Vortex Positive line (VI+)…

Overview
This strategy combines the Vortex Indicator and Moving Average lines to identify the direction and strength of price trends in order to generate potential long and short signals. When the Vortex Positive line (VI+) crosses above the Vortex Negative line (VI-), each crossover is highlighted on the chart. If the closing price is above the Moving Average line, a long signal is generated. When VI- crosses above VI+, if the closing price is below the Moving Average line, a short signal is generated.
Strategy Logic
Vortex Indicator: Consists of two lines - Vortex Positive (VI+) and Vortex Negative (VI-). It is used to identify the direction and strength of price trends.
Moving Average (MA): Uses a chosen Moving Average method (SMA, EMA, SMMA, WMA or VWMA) to smooth the price data. The smoothed line is referred to as the "Smoothing Line".
Determine Long and Short Signals: When VI+ crosses above VI-, each crossover is highlighted. If the close is above the Smoothing Line, a long signal is generated. When VI- crosses above VI+, if the close is below the Smoothing Line, a short signal is generated.
Advantages
Combines trend identification and smoothing to capture trends in trending markets, avoiding false signals in choppy markets.
Vortex Indicator effectively identifies trend direction and strength. Moving Averages filter out some noise.
Simple and clear strategy logic, easy to understand and implement.
Customizable parameters, adapts to different market environments.
Risks
May generate false signals and whipsaws in range-bound or trendless markets.
Inappropriate parameter settings can impact strategy performance. For example, a Moving Average that is too short has poor smoothing capability and a longer one lags in recognizing trend changes.
Unable to safeguard against extreme price swings from major unanticipated events.
Enhancements
Incorporate other indicators like volume to determine trend reliability.
Optimize parameters to balance trend-following and noise filtering of Moving Averages.
Add stop loss to control losses.
Utilize machine learning for automated parameter optimization.
Incorporate risk management modules to adjust position sizing.
Conclusion
This strategy effectively combines the Vortex Indicator and Moving Averages to capture trends. It identifies trend direction while having some noise filtering capability to reduce false signals. The logic is simple and flexible to use, performing well in trending markets. Further improvements in risk control can be achieved by incorporating more filters, optimizing parameters, and adding stop losses.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_int_1 | 14 | Vortex Length |
| v_input_int_2 | 9 | MA Length |
| v_input_1_close | 0 | Source: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4 |
| v_input_int_3 | false | Offset |
| v_input_string_1 | 0 | (?Smoothing)Method: SMA | EMA | SMMA (RMA) | WMA | VWMA |
| v_input_int_4 | 5 | Length |
Source Pine Script
/*backtest
start: 2023-02-01 00:00:00
end: 2024-02-01 00:00:00
period: 1d
basePeriod: 1h
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/
// © DraftVenture
//@version=5
strategy("Vortex + Moving Average Strategy", overlay=true)
//Vortex settings
period_ = input.int(14, title="Vortex Length", minval=2)
VMP = math.sum( math.abs( high - low[1]), period_ )
VMM = math.sum( math.abs( low - high[1]), period_ )
STR = math.sum( ta.atr(1), period_ )
VIP = VMP / STR
VIM = VMM / STR
plot(VIP, title="VI +", color=color.white)
plot(VIM, title="VI -", color=color.white)
len = input.int(9, minval=1, title="MA Length")
src = input(close, title="Source")
offset = input.int(title="Offset", defval=0, minval=-500, maxval=500)
out = ta.sma(src, len)
plot(out, color=color.blue, title="MA", offset=offset)
ma(source, length, type) =>
switch type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
typeMA = input.string(title = "Method", defval = "SMA", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Smoothing")
smoothingLength = input.int(title = "Length", defval = 5, minval = 1, maxval = 100, group="Smoothing")
smoothingLine = ma(out, smoothingLength, typeMA)
plot(smoothingLine, title="Smoothing Line", color=#f37f20, offset=offset, display=display.none)
// Determine long and short conditions
longCondition = ta.crossover(VIP, VIM) and close > smoothingLine
shortCondition = ta.crossunder(VIP, VIM) and close < smoothingLine
crossCondition = ta.crossunder(VIP, VIM) or ta.crossunder(VIM, VIP)
// Strategy entry and exit logic
if longCondition
strategy.entry("Long", strategy.long)
if shortCondition
strategy.entry("Short", strategy.short)
bgcolor(crossCondition ? color.new(color.white, 80) : na)
// Strategy by KPPublished by ChaoZhang on the FMZ strategy square · last modified 2024-02-02. 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/Spiral-Cross-Strategy-with-Moving-Average-Confirmation.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 and Moving Average Crossover Hybrid StrategyPine 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 MA Crossover Trend Tracking StrategyPine Script · Trend following · 1h
- Dual Mode Adaptive Trend Trading Strategy EMA Crossover with ATR Volatility Based Risk Management SystemPine Script · Trend following · 1d
- Dual Moving Average Crossover Dynamic Position Optimization Strategy with EMA Cross Signal SystemPine Script · Trend following · 1h