Example
What Is A State Machine
When driving a car down the street, you are in a given
state. When you receive input, you can remain in the
state of driving down the street, or you can change
states. Let's say you are driving down the
street; we will call that the "driving state." You
receive some input; you see a stop sign. Using
your eyes, and ears, you begin to evaluate several
decisions, and finally you move to the "deceleration
state." After further inputs and decisions,
you then move to the "stop state." From the "stop state,"
you receive more input and make more decisions; you may
enter the "acceleration state."
Lucky for you (and me) I'm not going to diagram a state
machine for driving a car. That would take a lot
of states, and a lot more decisions. I am going to
diagram a five-state state machine for drawing Darvas Boxes.
When you diagram a state machine, you use a state
diagram. Your only inputs will be the daily high and
low selling prices of a stock. That's not too bad, is
it?
The five different states are represented with rectangles.
The rectangles are numbered from one through five.
A state rectangle will also require you to do something.
This example of a state rectangle tells us to set
the BoxTop to Today's High.
The best way to teach you how to draw the Darvas Boxes
would be to illustrate to you how a computer program
would draw the boxes. I used a "state machine"
in my program to draw Darvas Boxes. The Darvas
Boxes are draw with a five-state state machine.
If it sounds complicated, it's not.
The decision box is a morph between a diamond and a rectangle. A decision box will ask you a question about the input you received. If the answer to the question is "yes", then follow the green arrow. If the answer to the question is "no", then follow the red arrow. Our example asks, "is the BoxTop greater than today's high?"
Darvas Box State Diagram
A Quick Summary
A Little More Detail
From state #1, move to the decision box. Ask yourself the question, "is
the BoxTop that I saved from state #1 greater than today's high?" If the
BoxTop that you saved from yesterday is bigger than today's high price, go
to state #2 and keep the BoxTop from yesterday. If the BoxTop that you
saved from yesterday is smaller than today's high, go back to state #1,
and set the BoxTop to today's high (a new BoxTop).
From state #2, move to the decision box. Ask yourself the same question, "is
the BoxTop that I saved from state #1 greater than today's high?" If the
BoxTop that you saved from two days ago is bigger than today's high price, go
to state #3 and keep the BoxTop that you got two day ago, plus you now get
to set the BoxBottom to today's low. If the Box Top that you saved from two
days ago is smaller than today's high, go back to state #1, and set the BoxTop
to today's high (a new BoxTop).
From state #3, move to the first decision box. Ask yourself the same question,
"is the BoxTop that I saved from days past greater than today's high?" If
today's high is greater than the BoxTop, you have to go all the way back to
state #1. On the other hand, if the BoxTop that you saved from days past is
still greater than today's high, you get to move to the second decision box.
Ask yourself the question, "is the BoxBottom that you saved from yesterday lower
than today's low selling price." If it is, you can move to State #4 and keep
yesterday's BoxBottom. On the other hand, if today's low is lower than the
saved BoxBottom, you go back to state #3, and set the BoxBottom to today's low.
State #4 is much like state #3. Move to the first decision box, and ask yourself
"is the BoxTop that I saved from day's past greater than today's high?" If today's
high is greater than the BoxTop, you will have to go all the way back to state #1.
On the other hand, if the BoxTop that you saved from days past is still greater
than today's high, you get to move to the second decision box. Ask yourself the
question, "is the BoxBottom that you saved from two days ago still lower than
today's low selling price." If the BoxBottom that you saved is higher than today's
low, you have to go back to State #3. Once in State #3, don't forget to set the
BoxBottom to today's low selling price. If you are lucky, you will have a BoxBottom
lower than today's low, and you will get to move to state #5. In state #5, you
have a valid BoxTop and a valid BoxBottom.
Once you are in state #5, you have created a Darvas Box. Simply wait until you
get a day's high selling price that is greater than your BoxTop (a buy signal)
or a day's low selling price that is lower than your BoxBottom (a sell signal).
Using the state diagram, you should be able to follow the candle stick chart
to see how the Darvas Boxes are drawn.
We are going to spend at least three days finding and validating the top
of a box (states #1, #2 and #3), and we are going to spend at least
three days finding and validating the bottom of a box (states #3, #4
and #5). Once we have reached state #5, we have a valid box top and
a valid box bottom -- a Darvas Box. Once we have reached state #5, we
simply wait until we get an input price greater than the top of the box
or less than the bottom of the box.
Once you have selected a stock to track, you will need to obtain the
high and low selling price of the stock for the day -- your input.
On day one, you start off in "state #1." This state
tells you to set the BoxTop to Today's high. Now what? Nothing, you
are done for the day. Only one state per day.
|
Copyright ©1996-2001, GerryCo. All rights reserved. This material is for personal use only. Republication and redisemination, including posting to news groups, is expressly prohibited without the prior written consent of GerryCo. Last updated on June 2001
|