Strategy vault / Mean reversion
WAMI Strategy
The WAMI Strategy is a trading strategy based on Fourier analysis that aims to find consistent and profitable trades on historical market data through an iterative optimization process. It combines the Exponential…

Overview
The WAMI Strategy is a trading strategy based on Fourier analysis that aims to find consistent and profitable trades on historical market data through an iterative optimization process. It combines the Exponential Moving Average (EMA), Weighted Moving Average (WMA), and Momentum indicator (MOM) to form a composite trading indicator called WAMI. When the WAMI crosses above or below a threshold, the strategy will issue buy or sell signals.
Strategy Logic
The core indicator of this strategy is WAMI. Its calculation is: first compute the momentum of price, then take the n-day WMA, and finally perform EMA twice to derive the final WAMI. Among them, momentum reflects the speed of price changes, WMA filters out short-term noise, and EMA smoothes the price.
When WAMI rises above a given threshold, a buy signal is generated, implying an uptrend is forming in the market. When it falls below the threshold, a sell signal is generated, meaning a downtrend has commenced. Users can adjust the threshold based on backtest results to better optimize the strategy.
Advantage Analysis
This strategy combines trend-following and overbought-oversold analysis, which can capture medium-to-long term price trends while avoiding being trapped. Compared to plain moving average strategies, WAMI improves the quality and consistency of trading signals.
The main advantages are:
- Fourier optimization improves parameter tuning
- Double EMA filter reduces false signals
- WMA+MOM combo improves sensitivity
- Flexible for both short and long-term trading
Risk Analysis
There are also some risks with this strategy:
- Optimization process is complex, improper settings may fail
- Performance decreases in ranging markets
- Performance highly depends on parameter settings
- Slow to switch on trend reversals
These risks can be reduced by adjusting parameter combinations, setting stop loss, and having reasonable profit expectations. The strategy should be stopped or position sized down when markets become excessively volatile.
Optimization Directions
Some aspects this strategy can be further optimized on:
- Test more parameter sets to find optimum
- Add supporting conditions like volume filter for entries
- Incorporate stop loss mechanisms
- Combine with other indicators to gauge overall trend
- Dynamically adjust parameters to fit changing market environments
Conclusion
In conclusion, the WAMI Strategy is a recommended medium-to-long term trend following strategy. By thoroughly analyzing price and volume changes, it generates quality trading signals. Given proper parameter optimization and risk control, this strategy can achieve steady profits. However, users should note that any strategy may fail, so prudent evaluation is a must before committing real capital.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 13 | Length_EMA |
| v_input_2 | 4 | Length_WMA |
| v_input_3 | false | Trigger |
| v_input_4 | false | Trade reverse |
Source Pine Script
/*backtest
start: 2022-12-06 00:00:00
end: 2023-12-12 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 17/01/2017
// The WAMI-based trading lies in the application and iteration of the
// optimization process until the indicated trades on past market data
// give consistent, profitable results. It is rather difficult process
// based on Fourier analysis.
// You can to change Trigger parameter for to get best values of strategy.
//
// You can change long to short in the Input Settings
// Please, use it only for learning or paper trading. Do not for real trading.
////////////////////////////////////////////////////////////
strategy(title="WAMI Strategy", shorttitle="WAMI Strategy")
Length_EMA = input(13, minval=1)
Length_WMA = input(4, minval=1)
Trigger = input(0)
reverse = input(false, title="Trade reverse")
hline(Trigger, color=purple, linestyle=line)
xWAMI = ema(ema(wma(mom(close, 1),Length_WMA),Length_EMA),Length_EMA)
pos = iff(xWAMI > Trigger, 1,
iff(xWAMI < Trigger, -1, nz(pos[1], 0)))
possig = iff(reverse and pos == 1, -1,
iff(reverse and pos == -1, 1, pos))
if (possig == 1)
strategy.entry("Long", strategy.long)
if (possig == -1)
strategy.entry("Short", strategy.short)
barcolor(possig == -1 ? red: possig == 1 ? green : blue )
plot(xWAMI, color=blue, title="WAMI")Published by ChaoZhang on the FMZ strategy square · last modified 2023-12-13. 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/WAMI-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
- Advanced Momentum EMA Trend Following with RSI Overbought Oversold Trading StrategyPine Script · Mean reversion · 1d
- Dynamic Adaptive Multi Timeframe Trend Following and Range Reversal Hybrid StrategyPine Script · Mean reversion · 2d
- Fast RSI Reversal Trading StrategyPine Script · Mean reversion · 1h
- Multi EMA Trend Reversal Trading StrategyPine Script · Mean reversion · 1d
- Elders Force Index Quantitative Trading Strategy Based on Standard Deviation and Moving AveragesPine Script · Mean reversion · 1d
- Enhanced Multi Indicator Trend Reversal Intelligence StrategyPine Script · Mean reversion · 1d