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

Using Arrays - how and when?



PureBytes Links

Trading Reference Links

Since the manual devotes a scant half-page to arrays, and since I still have
barely a clue on how to implement them, and, moreover, since I think such
information is vaguely important, I'd like to know exactly how and when
their use is appropriate.  I have a feeling I'll have to use one in the
system I'm writing, which is based on the identification of successive swing
lows, and selling on subsequent breaks below those swing lows.  So, if a
swing low is created on 3/1, and price breaks through that low on 3/4, a
short position is initiated at the original swing low price.  If another
swing low forms, on, say, 3/9, and that low is violated on 3/15, the system
should add a larger number of contracts to the initial position.  On each
subsequent swing low, should that low be violated at a later date, I want
the system to add contracts to the position.  The quantity of the add-ons
can remain constant, but it must be larger than the original entry position.
So, if I start with two lots, I want to add 5 lots on each violation of each
new swing low.  The statement I wrote to do this is

 IF Close < SwingLow[1] THEN begin;
 Sell 2 Contracts;

 IF MarketPosition < 0 AND SwingLow[1] <= SwingLow[2] THEN
 Sell 5 Contracts;
 end;

But this doesn't work.  I've tried all other kinds of configurations, and
the one that came closest was

IF Close < SwingLow THEN begin;
IF MarketPosition >= 0 THEN Sell 2 Contracts;
IF MarketPosition < 0  AND SwingLow[1] < SwingLow[2]
THEN Sell 5 Contracts;
end;

But this does not work, either.  It properly places the first entry, and the
first add-on, but after that, it doesn't add any more contracts.  That's why
I think I might need to use an array, and that's why I've provided all this
info about what I'm trying to accomplish.  If anyone's got any input,
general or specific (the more general, probably, the better), please send it
my way.

If the problem is with my sell statement, and I don't need to use an array
to store past values of the SwingLows, by all means let me know how to
change it so it works -- I'm pretty tired of this damn thing not working.

Thanks again everyone.

BJ