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.
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.
The advantages of this strategy include:
There are also some risks:
Countermeasures:
Some ways this strategy can be improved:
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.
/*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)