Weekend Range Trading Strategy
This strategy specifically trades the weekend price swings by determining long/short direction based on pre-set percentage bands. It is a typical range trading system. Strategy Logic: 1. Set percentage bands based on…
This strategy specifically trades the weekend price swings by determining long/short direction based on pre-set percentage bands. It is a typical range trading system.
Strategy Logic:
Set percentage bands based on previous Friday close, e.g. 4.5% up/down.
Enter short if price exceeds upside band, enter long if below downside band.
Add positions when reaching new bands in existing direction.
Take profit when accumulated gains reach threshold, such as 10%.
Allow maximum two simultaneous positions, one in each direction. Close all before Monday open.
Advantages:
Fixed percentage bands allow mechanical trading.
Multi-tier entries achieve better cost basis.
Periodicity is stable, unaffected by fundamentals.
Risks:
Unable to limit single trade loss size, risks large losing trades.
Fixed parameters fail to adapt changing volatility across periods.
Periodicity may change over time, invalidating the model.
In summary, this strategy frequently trades the weekend cycle but faces challenges locking in profits consistently. Exercise caution on parameter failure and outsized losses when applying.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 10 | Leverage |
| v_input_2 | 0.1 | Profit Taking Percent Threshold |
| v_input_3 | 2017 | Backtest Start Year |
| v_input_4 | 12 | Backtest Start Month |
| v_input_5 | 10 | Backtest Start Day |
| v_input_6 | 2025 | Backtest Stop Year |
| v_input_7 | 12 | Backtest Stop Month |
| v_input_8 | 30 | Backtest Stop Day |
| v_input_9 | true | Color Background? |
Source Pine Script
/*backtest
start: 2023-01-01 00:00:00
end: 2023-09-12 00:00:00
period: 2d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
//Copyright Boris Kozak
// strategy("XBT Weekend Trade Strategy", overlay=true, default_qty_type=strategy.percent_of_equity,)
strategy.initial_capital=50000
leverage = input(10,"Leverage")
profitTakingPercentThreshold = input(0.10,"Profit Taking Percent Threshold")
//****Code used for setting up backtesting.****///
testStartYear = input(2017, "Backtest Start Year")
testStartMonth = input(12, "Backtest Start Month")
testStartDay = input(10, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)
testStopYear = input(2025, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(30, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)
// A switch to control background coloring of the test period
testPeriodBackground = input(title="Color Background?", type=bool, defval=true)
testPeriodBackgroundColor = testPeriodBackground and (time >= testPeriodStart) and (time <= testPeriodStop) ? #00FFFF : na
bgcolor(testPeriodBackgroundColor, transp=50)
testPeriod() => true
//****END Code used for setting up backtesting.****///
//*** Main entry point is here***//
// Figure out how many days since the Friday close
days_since_friday = if dayofweek == 6
0
else
if dayofweek == 7
1
else
if dayofweek == 1
2
else
if dayofweek == 2
3
else
if dayofweek == 3
4
else
if dayofweek == 4
5
else
6
// Grab the Friday close price
fridaycloseprice = security(syminfo.ticker,'D',close[days_since_friday])
plot(fridaycloseprice)
// Only perform backtesting during the window specified
if testPeriod()
// If we've reached out profit threshold, exit all positions
if ((strategy.openprofit/strategy.initial_capital) > profitTakingPercentThreshold)
strategy.close_all()
// Only execute this trade on saturday and sunday (UTC)
if (dayofweek == 7.0 or dayofweek == 1.0)
// Begin - Empty position (no active trades)
if (strategy.position_size == 0)
// If current close price > threshold, go short
if ((close>fridaycloseprice*1.045))
strategy.entry("Short Entry", strategy.short, leverage)
else
// If current close price < threshold, go long
if (close<(fridaycloseprice*0.955))
strategy.entry("Long Entry",strategy.long, leverage)
// Begin - we already have a position
if (abs(strategy.position_size) > 0)
// We are short
if (strategy.position_size < 0)
if ((close>strategy.position_avg_price*1.045))
// Add to the position
strategy.entry("Adding to Short Entry", strategy.short, leverage)
else
if ((close<strategy.position_avg_price*0.955))
strategy.entry("Adding to Long Entry",strategy.long,leverage)
// On Monday, if we have any open positions, close them
if (dayofweek==2.0)
strategy.close_all()
Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-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/Weekend-Range-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
- Dual Bollinger Band Volatility Tracking StrategyPine Script · Volatility · 1d
- Dual EMA Volatility Adaptive Trading Strategy with Multi Tiered Profit Optimization SystemPine Script · Volatility · 1d
- Dual Moving Average Volatility Tracking StrategyPine Script · Volatility · 1h
- Dynamic ATR Trailing Stop Trading Strategy Market Volatility Adaptive SystemPine Script · Volatility · 1d
- Multi Indicator Dynamic Volatility Alert Trading SystemPine Script · Volatility · 1m
- Multi Indicator Volatility Trading RSI EMA ATR StrategyPine Script · Volatility · 3m