If you are familiar with the Darvas Box, you'll quickly realize that when the box lines are broken, there is no target level that price will tend to break to. This indicator adds a target level (CYAN dashed lines). Adding these target levels on the chart gives traders a perfect scalping trading tool. Place your entry trade at the box level and set your closing trade at the target line. This works on any timeframe. I also suggest adding a 20 EMA to your chart to see the trend level. You'll notice in the picture when the 20 is slopping down, Darvas Box target levels to the downside are hit. In the below example, the yellow arrows highlight targets being hit. There was one time that the box was broken and the target was not hit, highlighted with a yellow X. I updated this to make the box horizontal lines to clean the chart. I also added a 61.8 and a double target line.
I also added the 50% halfway line between the box levels. (yellow line). This can also be monitored for support and resistance. If the price can't break through the 50 yellow line, it is an early indication that the target may be hit. For example, in the below picture, price doesn't break above the 50, and it is used as resistance and the lower box level is broken and target is hit.
Check out the DAILY chart on SPY. It hits these targets.
download link: http://tos.mx/MWNNnFj
Enjoy!
I also added the 50% halfway line between the box levels. (yellow line). This can also be monitored for support and resistance. If the price can't break through the 50 yellow line, it is an early indication that the target may be hit. For example, in the below picture, price doesn't break above the 50, and it is used as resistance and the lower box level is broken and target is hit.
Check out the DAILY chart on SPY. It hits these targets.
download link: http://tos.mx/MWNNnFj
Code:
#
#
# TD Ameritrade IP Company, Inc. (c) 2011-2021
#
# Chewie added the 50 and 23.6 and 61.8 fib extentions and Double Target on 1/8/2022
input T1 = yes;
input T2 = yes;
input DT = yes;
def state = {default state_1, state_2, state_3, state_4, state_5};
def upper;
def lower;
def prevLower = CompoundValue(1, lower[1], low);
def prevUpper = CompoundValue(1, upper[1], high);
switch (state[1]) {
case state_1:
lower = low;
if (prevUpper >= high) {
upper = high[1];
state = state.state_2;
} else {
upper = high;
state = state.state_1;
}
case state_2:
if (prevUpper >= high) {
lower = low;
upper = prevUpper;
state = state.state_3;
} else {
lower = low;
upper = high;
state = state.state_1;
}
case state_3:
if (prevUpper < high) {
lower = low;
upper = high;
state = state.state_1;
} else if (prevLower > low) {
lower = low;
upper = prevUpper;
state = state.state_3;
} else {
lower = prevLower;
upper = prevUpper;
state = state.state_4;
}
case state_4:
if (prevUpper < high) {
lower = low;
upper = high;
state = state.state_1;
} else if (prevLower > low) {
lower = low;
upper = prevUpper;
state = state.state_3;
} else {
lower = prevLower;
upper = prevUpper;
state = state.state_5;
}
case state_5:
if (prevUpper < high) {
lower = low;
upper = high;
state = state.state_1;
} else if (prevLower > low) {
lower = low;
upper = high;
state = state.state_1;
} else {
lower = prevLower;
upper = prevUpper;
state = state.state_5;
}
}
def barNumber = BarNumber();
def barCount = HighestAll(If(IsNaN(close), 0, barNumber));
def boxNum;
def boxUpperIndex;
plot "Upper Band";
plot "Lower Band";
"Upper Band".setPaintingStrategy(paintingStrategy.HORIZONTAL);
"Lower Band".setPaintingStrategy(paintingStrategy.HORIZONTAL);
plot "Buy Signal" = CompoundValue(1, state[1] == state.state_5 and prevUpper < high, no);
plot "Sell Signal" = CompoundValue(1, state[1] == state.state_5 and prevLower > low, no);
if (IsNaN(close)) {
boxNum = boxNum[1] + 1;
boxUpperIndex = 0;
"Upper Band" = Double.NaN;
"Lower Band" = Double.NaN;
} else {
boxNum = TotalSum("Buy Signal" or "Sell Signal");
boxUpperIndex = fold indx = 0 to barCount - barNumber + 2 with valInd = Double.NaN
while IsNaN(valInd)
do if (GetValue(boxNum, -indx) != boxNum)
then indx
else Double.NaN;
"Upper Band" = GetValue(upper, -boxUpperIndex + 1);
"Lower Band" = GetValue(lower, -boxUpperIndex + 1);
}
"Upper Band".SetDefaultColor(color.dark_green);
"Lower Band".SetDefaultColor(Color.RED);
"Sell Signal".SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
"Sell Signal".SetDefaultColor(Color.RED);
"Buy Signal".SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
"Buy Signal".SetDefaultColor(color.dark_green);
plot FIB50 = ("Upper Band"-"Lower Band")/2 + "Lower Band";
FIB50.setDefaultColor(color.yellow);
FIB50.setPaintingStrategy(paintingStrategy.HORIZONTAL);
plot FIB236 = if T1 then ("Upper Band"-"Lower Band")*0.236 + "Upper Band" else double.nan;
FIB236.setDefaultColor(color.light_green);
FIB236.setPaintingStrategy(paintingStrategy.DASHES);
plot FIBN236 = if T1 then "Lower Band" -("Upper Band"-"Lower Band")*0.236 else double.nan;
FIBN236.setDefaultColor(color.PINK);
FIBN236.setPaintingStrategy(paintingStrategy.DASHES);
plot FIB618 = if T2 then ("Upper Band"-"Lower Band")*0.618 + "Upper Band" else double.nan;
FIB618.setDefaultColor(color.yellow);
FIB618.setPaintingStrategy(paintingStrategy.DASHES);
plot FIBN618 = if T2 then "Lower Band" -("Upper Band"-"Lower Band")*0.618 else double.nan;
FIBN618.setDefaultColor(color.yellow);
FIBN618.setPaintingStrategy(paintingStrategy.DASHES);
plot DTH = if DT then ("Upper Band"-"Lower Band") + "Upper Band" else double.nan;
DTH.setDefaultColor(color.GRAY);
DTH.setPaintingStrategy(paintingStrategy.DASHES);
plot DTL = if DT then "Lower Band" - ("Upper Band"-"Lower Band") else double.nan;
DTL.setDefaultColor(color.GRAY);
DTL.setPaintingStrategy(paintingStrategy.DASHES);
Last edited: