PureBytes Links
Trading Reference Links
|
At 12:14 AM -0400 8/17/98, Sentinel Trading wrote:
>
>At the risk of sounding ignorant and while enjoying some success daytrading,
>aided by TS what exactly is a dimensional array and why or when would it be
>used.
My application was that I had a variable that was a function of three other
variables:
Y = function of (S, J, K)
The relationship I wanted was pretty complex and the variables S, J, and K
could only have the integer values of 0 through 7. So I thought I would
just use a look-up table of the values rather than try to approximate the
relationship with equations.
To do this I would use a 3 dimensional array which would look like a cube
with 8 cells on each edge, for a total of 512 cells (= 8 * 8 * 8).
I would have to load the array on the first bar with the values I wanted:
if CurrentBar = 1 then begin
NS[0,0,0] = 00; NS[0,0,1] = 01; NS[0,0,2] = 02; NS[0,0,3] = 03;
NS[0,0,4] = 04; NS[0,0,5] = 05; NS[0,0,6] = 06; NS[0,0,7] = 07;
NS[0,1,0] = 10; NS[0,1,1] = 11; NS[0,1,2] = 12; NS[0,1,3] = 13;
NS[0,1,4] = 14; NS[0,1,5] = 15; NS[0,1,6] = 16; NS[0,1,7] = 17;
NS[0,2,0] = 20; NS[0,2,1] = 21; NS[0,2,2] = 22; NS[0,2,3] = 23;
NS[0,2,4] = 24; NS[0,2,5] = 25; NS[0,2,6] = 26; NS[0,2,7] = 27;
NS[0,3,0] = 30; NS[0,3,1] = 31; NS[0,3,2] = 32; NS[0,3,3] = 33;
..........etc.
end;
(These are not the real values I wanted, only an illustration.)
Then, when I needed a value, I could simply read the value from the table:
Y = NS[S, J, K];
An example of when you might use this is if you wanted to decide how many
contracts to buy based upon three different variables in a relationship too
complex to specify in an equation.
Such table look-ups are frequently used in other programming applications
since they are very fast and allow you to retrieve any values you want.
(Most programming languages have more flexible methods of loading up the
array with the values you want.)
Bob Fulks
|