[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Dynamic Zones



PureBytes Links

Trading Reference Links


Here's my implementation of the Dynamic Zones concept in an indicator.

Caveat: I haven't spent a ton of time debugging this, so there's a chance I
might have goofed somewhere. But it seems to be working as it should.

On the other hand, I'm pretty sure that the code could be made more
efficient, so I'd be happy to hear any suggestions along those lines.

For those not familiar with the DZ concept, it's based on an article by the
RINA Systems folks published in Stocks & Commodities a while back. (I think
their website also provides a description.)

The basic idea is to sort the N most recent values of an indicator & then
construct bands such that X% of the values fall above/ below the most recent
value.

In the example below, the 50 most recent values of RSI are stored and X =
10%.

Note that it would be relatively trivial to convert this indicator to a
function which could then be used in a system, thusly:

BuyLevel = Sorted[Bottom];
SellLevel = Sorted[Top];
If Indicator crosses above BuyLevel then Buy at the market;
If Indicator crosses below SellLevel then Sell at the market;

Anyway, hope this proves useful. Seems silly to pay RINA $200-300 for
something's that's not all that hard to code ...

It'd be nice to see more code and/ or new trading concepts on the list ...

Cheers,

Cab Vinton
cvinton@xxxxxxxxxxx


INDICATOR CODE FOLLOWS:

Inputs: Varr(RSI(C,14)), Top(44), Bottom(4);
Arrays: Values[49](-1), Sorted[49](-1);
Vars: j(0), m(0), best(0), bestk(0);

{Store the 50 most recent values
Should probably use a circular array here}
For j = 49 downto 1 begin
	Values[j] = Values[j-1];
End;
Values[0] = Varr;

{Copy values to Sorting array}
For j = 0 to 49 begin
	Sorted[j] = Values[j];
End;

{Use SelectionSort to sort the values once array has been filled}
If Values[49] <> -1 then begin
	For j = 0 to 48 begin
		best = Sorted[j];
		bestk = j;
		For m = j + 1 to 49 begin
			If Sorted[m] < best then begin
				best = Sorted[m];
				bestk = m;
			End;
		End;
		Sorted[bestk] = Sorted[j];
		Sorted[j] = best;
	End;

	Plot1(Varr,"X");
	Plot2(Sorted[Bottom],"Y");
	Plot3(Sorted[Top],"Z");

End;