Darvas Box Theory — Tracking Uptrends

The Darvas box theory is based on the work of Nicolas Darvas, author of the book "How I Made $2 Million in the Stock Market". This indicator uses his box theory to help visualize upward trends and find potential opportunities to buy or add to a position.

Darvas was a growth stock trader. After extensive study of historical stock movements, Darvas noted stocks "have a defined upward or downward trend which, once established, tended to continue. Within this trend stocks moved in a series of frames, or what I began to call boxes."

Darvas Box Theory
■ A box defines a high and low range that contains a stock's movement over a period of time.
■ Darvas preferred "lively" stocks that moved up and down within a box. In his research, Darvas noted stocks with these characteristics often had significant moves up.
■ Boxes stacked one after another often indicate a strong upward trend.
■ A potential buy signal is a stock moving past the high of the topmost box with a significant increase in volume .
■ Within the range of a box, Darvas considered movement to the bottom of the range a healthy sign. These moves down shakeout weak holders who sell thinking the downward trend may continue.

Defining a Box:
■ After price makes a new high, there must be three consecutive bars that don't exceed the high.
■ Once the top of the box is set, the same process is used, in reverse, to determine the bottom.
■ Once the high and low are established, a box is drawn over the range of bars.
■ With this indicator, there are two options to determine when a box is complete, that is, when a box is fully enclosed and a new box can be started. The default is when there is a close above or below the high or low of the box. Using the close may provide a better perspective of the overall trend by limiting noise of price movements within a bar. The second option to complete a box is when a bar's high or low goes above or below the boundaries of the box. The preferred option is configurable within the indicator Settings.

Lookback Range
■ The lookback range is used to determine if the current bar has reached a new high, which could indicate the start of a new box.
■ The value specified for the lookback determines how many bars back to compare against the current bar high.
■ You can set the lookback value for intraday, daily and weekly charts.
■ It's recommended to experiment with lookback values across various timeframes to find settings that fit with your trading style.

Suggestions from Darvas:
■ The box theory works best during a strong uptrend, where boxes stack one after another.
■ When breaking through the top of the box, ideally there will be a significant increase in volume . This may be an opportunity to buy or add to a position.
■ Try and hold stocks that are consistently moving up by raising a stop-loss along with the rise.
■ Take losses quickly.

Indicator Features:
■ Box completion can be based on a close above/below the box boundaries or a move above/below the box boundaries.
■ Configure the lookback range for intraday, daily and weekly charts.
■ Configure box borders and background colors.
■ When the last bar is within a box, show an optional breakout price indicating a move above the top of box.

Release Notes: Version 2.0

What's New:
■ Option to show distance to breakout price (box highest high) as a percentage.
Release Notes: Version 3.0

What's New:
■ Custom alerts on break above box high or below box low.
■ Option to show distance in price and percentage to box high and/or low.
Release Notes: Version 4.0

What's New:
■ Allow price/percentage labels to be adjusted left/right in relation to the last bar.
Protected script
This script is published closed-source and you may use it freely. You can favorite it to use it on a chart. You cannot view or modify its source code.
Want to use this script on a chart?
30+ years in software dev. Technology author. Growth stock and crypto trader. Technical analysis geek.

If you find my indicators helpful, please consider a donation:

BTC: 36A51Xdi4HVGYxH86kRvQ74Tzp5xWU1HvU


Are there any options to get the source code or buy it?
+4 Reply
Thanks for your interest in the script. Although this project is not open source, I'm open to ideas and suggestions for future updates.
hi,can you please allow me to use this scanner?
+2 Reply
JohnMuchow sniggletsnaukri
You can install the indicator from the "Indicators" menu in TradingView.
Great code. I coded same but was getting boxes inside boxes.
Love to see the code to learn and implement.
Please open source it for developers
+2 Reply
JohnMuchow pkopensrc
Thanks for your interest in the script. Although this project is not open source, I'm open to ideas and suggestions for future updates.
Hi John.
First of all amazing work. This is really useful and works incredibly well.

Two comments:
- You did not link the average volume vs daily during breakout in the script, right?
- would it be possible to add alert conditions? It would awesome for Pyramiding: Once a Darvas Box turns out green and the volume is nix, you could add to you current position.

+2 Reply
JohnMuchow Bierbaron
I am coding/testing some ideas for alerts. I'll publish an update once things are complete.
+1 Reply
Bierbaron JohnMuchow
@JohnMuchow, thanks a lot John! Great News!
Great visual again John, way more pleasing than yahoo #darvas box , even so it has vey good calibrations .
+1 Reply