Weekly Breakthrough Moving Average Trading Strategy
This strategy trades based on the weekly closing price of Bitcoin and the 8-week simple moving average. It goes long when the weekly closing price breaks above the 8-week line and closes the position when the weekly…

Overview
This strategy trades based on the weekly closing price of Bitcoin and the 8-week simple moving average. It goes long when the weekly closing price breaks above the 8-week line and closes the position when the weekly closing price breaks below the 8-week line. It also sets stop loss and take profit ratios to control risks.
Strategy Logic
This strategy analyzes the weekly price action of Bitcoin and the 8-week simple moving average to judge if the market is in an uptrend or a downtrend. When the weekly closing price breaks above the 8-week line, it signals that the market has entered an uptrend channel and a long position could profit. When the weekly closing price breaks below the 8-week line, it signals that the Bitcoin weekly chart has entered a downtrend channel and existing long positions should be stopped out.
Specifically, the following trading conditions are set in the strategy:
buy_condition = crossover(btc,ma) #weekly closing price breaks above 8-week line, go long
sell_condition = crossunder(btc,ma) #weekly closing price breaks below 8-week line, close position
When the buy condition is met, the strategy goes long. When the sell condition is triggered, the strategy exits with either take profit or stop loss.
In addition, stop loss and take profit ratios are configured:
loss_ratio=input(defval=1,title="LOSS RATIO", group="STRATEGY")
reward_ratio=input(defval=3,title="REWARD RATIO", group="STRATEGY")
The default stop loss ratio is 1 and default take profit ratio is 3. This means that when exit signal comes, if currently profitable, exit with 3 times profit. If currently loss, exit with 1 times loss.
Advantage Analysis
The advantages of this strategy include:
- Weekly timeframe, less drawdown, suitable for long term holding
- 8-week MA filters out noise and identifies major trends
- Stop loss and take profit controls risk
Risk Analysis
There are also some risks:
- Unable to adjust position based on short-term price action
- Breakout signals may have false signals
- Stop loss/take profit may fail during extreme market events
Countermeasures:
- Combine with other short-term indicators to catch short-term opportunities
- Add filters to avoid false signals
- Adjust stop loss/take profit ratios based on market conditions to limit losses
Optimization Directions
Some ways this strategy can be improved:
- Add additional filters to ensure valid breakout signals
- Optimize stop loss and take profit ratios
- Incorporate short-term indicators for multi-timeframe analysis
- Use machine learning to auto-optimize parameters
Conclusion
In summary, this is a simple and straightforward strategy that judges trend based on weekly breakouts and moving average. It also controls risk via stop loss and take profit. It can serve as a reference system for long-term Bitcoin holdings. But there are some limitations that can be improved on signal quality, parameter tuning, multi-timeframe analysis etc.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1_close | 0 | (?STRATEGY)source: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4 |
| v_input_7 | true | LOSS RATIO |
| v_input_8 | 3 | REWARD RATIO |
| v_input_2 | #FF3232 | (?MA)COLOR |
| v_input_3 | 2 | LINE WIDTH |
| v_input_4 | #6666FF | (?GRAPHIC)COLOR |
| v_input_5 | 2 | LINE WIDTH |
| v_input_6 | 2020 | (?STRATEGY EXECUTION YEAR)YEAR |
Source Pine Script
/*backtest
start: 2024-01-10 00:00:00
end: 2024-01-17 00:00:00
period: 3m
basePeriod: 1m
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/
// © taberandwords
//developer: taberandwords
//author: taberandwords
//@version=4
strategy("WEEKLY BTC TRADING SCRYPT","WBTS",overlay=false,default_qty_type=strategy.fixed)
source=input(defval=close,title="source",group="STRATEGY")
btc=security('BTCUSDT','1W', source)
ma=sma(btc,8)
buy_condition= crossover(btc,ma)
sell_condition= crossunder(btc,ma)
ma_color=input(defval=#FF3232,title="COLOR",group="MA")
ma_linewidth=input(defval=2,title="LINE WIDTH",group="MA")
graphic_color=input(defval=#6666FF,title="COLOR",group="GRAPHIC")
graphic_linewidth=input(defval=2,title="LINE WIDTH",group="GRAPHIC")
start_date=input(defval=2020,title="YEAR",group="STRATEGY EXECUTION YEAR")
loss_ratio=input(defval=1,title="LOSS RATIO", group="STRATEGY")
reward_ratio=input(defval=3,title="REWARD RATIO", group="STRATEGY")
if(year>=start_date)
strategy.entry('BUY',long=true,when=buy_condition,alert_message='Price came to buying value!')
if(strategy.long)
alert('BTC buy order trigerred!',alert.freq_once_per_bar)
strategy.exit(id="SELL",loss=loss_ratio,profit=reward_ratio,when=sell_condition,alert_message='Price came to position closing value!')
if(sell_condition)
alert('BTC sell order trigerred!',alert.freq_once_per_bar)
plot(series=source,title="WEEKLY CLOSE",color=graphic_color,linewidth=graphic_linewidth)
plot(ma,title="SMA8 WEEKLY",color=ma_color,linewidth=ma_linewidth)
plot(strategy.equity,display=0)
Published by ChaoZhang on the FMZ strategy square · last modified 2024-01-18. 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/Weekly-Breakthrough-Moving-Average-Trading-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
- 5 Day Moving Average Channel Breakout Strategy Combined With Mileage ConceptPine Script · Breakout · 1d
- Adaptive Bollinger Breakout with Moving Average Quantitative Strategy SystemPine Script · Breakout · 1h
- Adaptive Multi Period Trading Strategy Based on Wave Trend Momentum BreakoutPine Script · Breakout · 2h
- Adaptive Trading Strategy Based on ADX IndicatorPine Script · Breakout · 1d
- Average Line Breakthrough StrategyPine Script · Breakout · 1d
- BB Breakout StrategyPine Script · Breakout · 1d