52 Week High Low Box Trading Strategy
The 52 Week High Low Box Trading Strategy is a strategy that uses the "boxes" formed by price oscillating in different ranges as trading signals. The core logic of this strategy is that when the price breaks through…

Overview
The 52 Week High Low Box Trading Strategy is a strategy that uses the "boxes" formed by price oscillating in different ranges as trading signals. The core logic of this strategy is that when the price breaks through the upper or lower limit of a certain range (box), it indicates that the price is entering a new range, at which point a long or short position can be opened.
Strategy Principle
This strategy calculates the highest high and lowest low over the past 5 days (adjustable) to determine if the price has entered a new trading range. The specific rules are:
Calculate the highest high and lowest low over the most recent 5 days to form a trading range box.
When the price breaks above the upper limit of this range, it indicates that it may be entering a higher range and a long position can be opened.
When the price drops below the lower limit of this range, it indicates that it may be entering a lower range and a short position can be opened.
Set the stop loss near the upper/lower limit of the previous range to control risk.
Repeat the above judgments and continuously adjust the trading range to realize profits.
Using such breakthroughs to determine trends and generate trading signals is the core idea of this strategy.
Advantage Analysis
The 52 Week High Low Box Trading Strategy has the following advantages:
The strategy logic is simple and intuitive, easy to understand and implement.
It can capture trending moves after prices enter new ranges. Range breakouts are relatively reliable trading signals.
There is a clear stop loss strategy that can effectively control risk.
The range length can be adjusted to adapt to different cycle ranges and different varieties.
In general, this is a trend trading strategy with good risk control capabilities and practicality.
Risk Analysis
The strategy also has some risks, mainly including:
When the trend is not obvious, multiple small losses may occur.
Improper range settings also increase the probability of erroneous trades.
The stop loss strategy cannot completely avoid the risk of huge price gaps.
This requires traders to continuously test and optimize the parameters of the strategy in practice and carefully manage risks.
Optimization Directions
The 52 Week High Low Box Trading Strategy can also be optimized in the following aspects:
Combine trading volume or moving average indicators to verify buy and sell signals and improve accuracy.
Optimize the length parameters of the box to adapt to market changes.
After breakthrough purchases, waiting for pullbacks to form more chances for re-entry.
Use the compounding principle to appropriately increase positions on each stop loss to pursue higher returns.
Through parameter adjustment and rule optimization in the implementation process, the effect of this strategy can be continuously improved.
Summary
The 52 Week High Low Box Trading Strategy is a strategy that determines trend direction based on price breakouts. It has simple trading logic and strong risk control capabilities. Continuous testing and optimization is needed in practice to fully exploit the advantages of this strategy. Overall, this is a recommended practical trading strategy.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 5 | BOX LENGTH |
Source Pine Script
/*backtest
start: 2023-11-10 00:00:00
end: 2023-12-10 00:00:00
period: 1h
basePeriod: 15m
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/
// © ceyhun
//@version=4
strategy ("Darvas Box Strategy",overlay=true)
boxp=input(5, "BOX LENGTH")
D_High = security(syminfo.tickerid, 'D', high)
D_Low = security(syminfo.tickerid, 'D', low)
D_Close = security(syminfo.tickerid, 'D', close)
D_Open = security(syminfo.tickerid, 'D', open)
LL = lowest(D_Low,boxp)
k1 = highest(D_High,boxp)
k2 = highest(D_High,boxp-1)
k3 = highest(D_High,boxp-2)
NH = valuewhen(D_High>k1[1],D_High,0)
box1 = k3<k2
TopBox = valuewhen(barssince(D_High>k1[1])==boxp-2 and box1, NH, 0)
BottomBox = valuewhen(barssince(D_High>k1[1])==boxp-2 and box1, LL, 0)
plot(TopBox, linewidth=2, color=#00FF00, title="TopBox")
plot(BottomBox, linewidth=2, color=#FF0000, title="BottomBox")
if crossover(D_Close,TopBox)
strategy.entry("Long", strategy.long, comment="Long")
if crossunder(D_Close,BottomBox)
strategy.entry("Short", strategy.short, comment="Short")
Published by ChaoZhang on the FMZ strategy square · last modified 2023-12-11. 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/52-Week-High-Low-Box-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
- ATR Trailing Stops StrategyPine Script · Breakout · 1h
- ATR Trend Breakout StrategyPine Script · Breakout · 1d
- Adaptive Bollinger Breakout with Moving Average Quantitative Strategy SystemPine Script · Breakout · 1h
- Adaptive Channel Breakout StrategyPine Script · Breakout · 1d
- Adaptive Multi Period Trading Strategy Based on Wave Trend Momentum BreakoutPine Script · Breakout · 2h