I've been reviewing Jack's camtasia videos (again) and have been trying to sort out the stop offset that he talks about. The way I understand it, we want to look for the places where the price drops in one day but recovers the next and resumes its journey. If we find these, we will know just how far the stock typically goes in it's "normal" progress so that we can distinguish normal fluctuation from a reversal.
When looking at the results of the Bruno R v2 chartscript, the figures don't seem to match my intuition. Digging deeper into the code, I think I see why. It looks like the code is comparing the difference between the lows of any two consecutive days, records the max 10 differences, and then takes an average (with a 1.1 fudge factor).
But my understanding is that we should be only looking for days where the low is below the bars on either side. When I experimented with the code, it seemed that my changes didn't make a huge difference.
I studied the charts again, and see that there are many "false positives", where, during a drop, there will be a large drop in one day and a minor recovery the next, just enough to get the large drop recorded as a spike, though it was nothing of the sort.
I'm scratching my head now, trying to figure out the best way to programatically catch these and wanted to throw it open to the group.
Here is what I have now (using an array instead of lots of variables):
Code:
// replace B1 - B10
var Spikes: array[1..10] of float;
var index: integer;
var barLeft, barRight, spike: float;
var temp: float;
// ...
{Stop Offset Code}
// initialize
for index:= 1 to 10 do
Spikes[index] := 0;
// scan for spikes
for Bar := BarCount() -137 to BarCount - 1 do
begin
barLeft := PriceLow(bar-2);
barRight := PriceLow(bar);
if (PriceLow(bar-1) < barLeft) AND (PriceLow(bar-1) < barRight) THEN
begin
spike := Min((barLeft - PriceLow(bar-1)),(barRight - PriceLow(bar-1)));
for index:= 1 to 10 do
begin
if Spikes[index] < spike then
begin
// swap
temp := Spikes[index];
Spikes[index] := spike;
spike := temp;
end; // if
end; // for
end; // if
end; // for
BarTotal := 0;
for index:= 1 to 5 do
BarTotal := BarTotal + Spikes[index];
BarTotal := (BarTotal / 5) * 1.1;
I think I'm making two mistakes which are missing the spirit of Jack's stop offset. First, I am checking to see if the lows of the bars to either side are greater, and then I consider this a spike. I don't think that's quite right.
Second, I'm taking the min of the distance between the lows on either side as the magnitude of the spike. I think that's close, but I'm not so confident. Maybe when we take the top five values and then average them out, all of these minor false positives will fall by the wayside.
Does anyone have any comments? I'm very much a newbie here, and think I may be making a conceptual mistake somewhere, so if you can fix my thinking, that would be great.
If no one can see anything obviously wrong, maybe someone can volunteer to help me out. I'd like to manually calculate the stop offset for a few stocks, figure out what we did, and then try to do that in code.
Thanks all.