Momentum Squeeze Strategy
The main idea of this strategy is to combine Lazy Bear's momentum indicator and Crypto Face's MFI indicator to go long when the trend goes up and go short when the trend goes down, realizing a quantitative trading…

Overview
The main idea of this strategy is to combine Lazy Bear's momentum indicator and Crypto Face's MFI indicator to go long when the trend goes up and go short when the trend goes down, realizing a quantitative trading strategy that follows market trends.
Strategy Logic
Use Lazy Bear's momentum indicator BlueWave, which calculates the linear regression of close price versus the 20-day highest high, lowest low and close average to determine the trend direction. When BlueWave crosses above 0, it indicates an upward trend; when it crosses below 0, it indicates a downward trend.
Use the improved MFI indicator by Crypto Face, which calculates the sum of price change and volume over the past 58 days to determine the money flow. MFI greater than 0 indicates money inflow, less than 0 indicates outflow.
When BlueWave crosses above 0 and MFI is greater than 0, a buy signal is generated to open a long position; when BlueWave crosses below 0 and MFI is less than 0, a sell signal is generated to open a short position.
Set stop loss and take profit conditions to follow the market trend for profit, while controlling risks.
Advantages
Combining two indicators can more accurately determine market trend direction.
BlueWave's smooth curve avoids bias from outliers, making trend judgement more reliable.
MFI can determine money flow, avoiding losses from false breakouts.
The strategy has few parameters and is easy to implement and operate.
Flexible stop loss and take profit settings help control trading risks.
Trading sessions can be set to avoid abnormal volatility during specific market times.
Risks
Continued downtrend may lead to successive short positions and losses.
False signals may lead to being trapped after entering positions.
Oversized stop loss may amplify losses.
High volatility may frequently hit stop loss points.
Improper parameter optimization may lead to poor strategy performance.
Too frequent trading signals may increase transaction costs and slippage.
Enhancement
Optimize parameters of BlueWave and MFI for more steady and reliable signals.
Incorporate trend indicators to avoid sustained short losses.
Dynamically adjust stop loss/take profit ratios to lower being trapped probability.
Refine entry conditions to reduce false signals.
Consider position sizing to avoid chasing rallies and dumping dips.
Combine with machine learning models for more accurate entry and exit points.
Conclusion
This strategy combines BlueWave and MFI indicators to determine trend direction, going long on uptrends and short on downtrends, effectively following market trends for profits. However, risks exist in parameter settings, stop loss/take profit, sustained downtrends etc, requiring further optimization on parameter tuning, stop loss mechanisms, filter conditions etc to improve strategy performance and robustness. Overall, the strategy is intuitive and works well for long-term trend following, but losses may be incurred when trapped in ranging markets.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | true | (?SL/TP For Long Strategy)Enable Long Strategy |
| v_input_2 | 50 | Stoploss % |
| v_input_3 | 50 | Take Profit % |
| v_input_4 | true | (?SL/TP For Short Strategy)Enable Short Strategy |
| v_input_5 | 50 | Stoploss % |
| v_input_6 | 50 | Take Profit % |
| v_input_7 | true | (?Date Range)Start Date |
| v_input_8 | true | Start Month |
| v_input_9 | 1804 | Start Year |
| v_input_10 | true | End Date |
| v_input_11 | true | End Month |
| v_input_12 | 2077 | End Year |
Source Pine Script
/*backtest
start: 2022-11-07 00:00:00
end: 2023-11-13 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// @version=4
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Bunghole 2021
strategy(title="Crypto Squeeze Strategy", initial_capital = 100000, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 0, currency = 'USD', overlay=true)
//// Stoploss and Take Profit Parameters
// Enable Long Strategy
enable_long_strategy = input(true, title="Enable Long Strategy", group="SL/TP For Long Strategy",inline="1")
long_stoploss_value = input(defval=50, title='Stoploss %', type=input.float, minval=0.1, group="SL/TP For Long Strategy",inline="2")
long_stoploss_percentage = (close * (long_stoploss_value / 100)) / syminfo.mintick
long_takeprofit_value = input(defval=50, title='Take Profit %', type=input.float, minval=0.1, group="SL/TP For Long Strategy",inline="2")
long_takeprofit_percentage = (close * (long_takeprofit_value / 100)) / syminfo.mintick
// Enable Short Strategy
enable_short_strategy = input(true, title="Enable Short Strategy", group="SL/TP For Short Strategy",inline="3")
short_stoploss_value = input(defval=50, title='Stoploss %', type=input.float, minval=0.1, group= "SL/TP For Short Strategy",inline="4")
short_stoploss_percentage = (close * (short_stoploss_value / 100)) / syminfo.mintick
short_takeprofit_value = input(defval=50, title='Take Profit %', type=input.float, minval=0.1, group="SL/TP For Short Strategy",inline="4")
short_takeprofit_percentage = (close * (short_takeprofit_value / 100)) / syminfo.mintick
// Plot Stoploss & Take Profit Levels
long_stoploss_price = strategy.position_avg_price * (1 - long_stoploss_value/100)
long_takeprofit_price = strategy.position_avg_price * (1 + long_takeprofit_value/100)
short_stoploss_price = strategy.position_avg_price * (1 + short_stoploss_value/100)
short_takeprofit_price = strategy.position_avg_price * (1 - short_takeprofit_value/100)
plot(enable_long_strategy and not enable_short_strategy ? long_stoploss_price: na, color=#ff0000, style=plot.style_linebr, linewidth=2, title="Long SL Level")
plot(enable_long_strategy and not enable_short_strategy ? long_takeprofit_price: na, color=#008000, style=plot.style_linebr, linewidth=2, title="Long TP Level")
plot(enable_short_strategy and not enable_long_strategy ? short_stoploss_price: na, color=#ff0000, style=plot.style_linebr, linewidth=2, title="Short SL Level")
plot(enable_short_strategy and not enable_long_strategy ? short_takeprofit_price: na, color=#008000, style=plot.style_linebr, linewidth=2, title="Short TP Level")
// Date Range
start_date = input(title="Start Date", type=input.integer, defval=1, minval=1, maxval=31, group="Date Range")
start_month = input(title="Start Month", type=input.integer, defval=1, minval=1, maxval=12, group="Date Range")
start_year = input(title="Start Year", type=input.integer, defval=1804, minval=1800, maxval=3000, group="Date Range")
end_date = input(title="End Date", type=input.integer, defval=1, minval=1, maxval=3, group="Date Range")
end_month = input(title="End Month", type=input.integer, defval=1, minval=1, maxval=12, group="Date Range")
end_year = input(title="End Year", type=input.integer, defval=2077, minval=1800, maxval=3000, group="Date Range")
in_date_range = (time >= timestamp(syminfo.timezone, start_year, start_month, start_date, 0, 0)) and (time < timestamp(syminfo.timezone, end_year, end_month, end_date, 0, 0))
//// Indicator Inputs
// Lazy Bear's Momentum Indicator
BlueWave = linreg(close - avg(avg(highest(high, 20), lowest(low, 20)), sma(close, 20)), 20, 0)
// Replicated version of Crypto Face's MFI Indicator
mfiUpper = sum(volume * (change(hlc3) <= 0 ? 0 : hlc3), 58)
mfiLower = sum(volume * (change(hlc3) >= 0 ? 0 : hlc3), 58)
_mfiRsi(mfiUpper, mfiLower) =>
if mfiLower == 0
100
if mfiUpper == 0
0
100.0 - (100.0 / (1.0 + mfiUpper / mfiLower))
mf = _mfiRsi(mfiUpper, mfiLower)
mfi = (mf - 50) * 3
//// Strategy
// Creating Long and Short Strategy
buy_signal = crossover(BlueWave, 0) and mfi > 0
sell_signal = crossunder(BlueWave, 0) and mfi < 0
// Long Strategy
if buy_signal and in_date_range and enable_long_strategy == true
strategy.entry("Long", true, when=buy_signal, alert_message="Open Long Position")
strategy.exit("Long SL/TP", from_entry="Long", loss=long_stoploss_percentage, profit=long_takeprofit_percentage, alert_message="Your Long SL/TP Limit As Been Triggered.")
strategy.close("Long", when=sell_signal, alert_message="Close Long Position")
// Short Strategy
if sell_signal and in_date_range and enable_short_strategy == true
strategy.entry("Short", false, when = sell_signal, alert_message="Open Short Position")
strategy.exit("Short SL/TP", from_entry="Short", loss=short_stoploss_percentage, profit=short_takeprofit_percentage, alert_message="Your Short SL/TP Limit As Been Triggered.")
strategy.close("Short", when=buy_signal, alert_message="Close Short Position")
Published by ChaoZhang on the FMZ strategy square · last modified 2023-11-14. 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/Momentum-Squeeze-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
- ADX Momentum Trend StrategyPine Script · Momentum · 10m
- Adaptive Trend Following Strategy Based on Momentum OscillatorPine Script · Momentum · 1d
- Bollinger Bands Momentum Trend Following Quantitative StrategyPine Script · Momentum · 1d
- Confirmed SMA Crossover Momentum StrategyPine Script · Momentum · 1d
- Cross Momentum Trend Following Strategy SMA RSI Cross Momentum SystemPine Script · Momentum · 1h
- Dual Moving Average Momentum Trading Strategy Time Optimized Trend Following SystemPine Script · Momentum · 2m