Welcome to the Traders Laboratory.

Coding Forum Collaborate, receive help, or discuss indicators and other coding-related topics

Reply
Old 04-20-2009, 09:03 AM   #1

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 4,052
Ignore this user

Thanks: 2,275
Thanked 1,661 Times in 1,010 Posts

Array (EasyLanguage)

This thread is about Arrays.




Array
Declares one or more names as arrays, containing multiple variable data elements; specifies the array structure, data elements type and initial value, update basis, and data number, for each of the arrays.

Data elements type can be numerical, string, or true/false.

The number of elements in an array can be fixed or dynamic (unlimited).

In arrays with a fixed number of elements, the elements can be arranged in single or multiple dimensions.

A one-dimensional 10-element array contains 10 elements,
a two-dimensional 10-element by 10-element array contains 100 elements,
a three-dimensional 10 by 10 by 10 element array contains 1000 elements,
a four-dimensional 10 by 10 by 10 by 10 element array contains 10000 elements, etc.

The maximum number of array dimensions in EasyLanguage is 9.

Each element in an array is referenced by one or more index numbers, one for each of the dimensions. Indexing starts at 0 for each of the dimensions.

Dynamic arrays (arrays with an unlimited number of elements) are one-dimensional, and are initialized at declaration as having only one element. Declared dynamic arrays can be resized using Array_SetMaxIndex.

Elements can be manipulated individually or as a group, in all or part of an array.

Usage
Array:<IntraBarPersist>Ar rayName1[D1,D2,D3,etc.](InitialValue1<,DataN>),
<IntraBarPersist>ArrayNam e2[D1,D2,D3,etc.](InitialValue2<,DataN>),
etc...

Parameters inside the angled brackets are optional

Parameters
IntraBarPersist - an optional parameter; specifies that the value of the array elements is to be updated on every tick
If this parameter is not specified, the value will be updated at the close of each bar.

ArrayName - an expression specifying the array name
The name can consist of letters, underscore characters, numbers, and periods. The name cannot begin with a number or a period and is not case-sensitive.


D - a numerical expression specifying the array size in elements, starting at 0, for each of the dimensions;
a single expression specifies a one-dimensional array,
two expressions specify a two-dimensional (D1 by D2) array,
three expressions specify a three-dimensional (D1 by D2 by D3) array, etc.
A dynamic array, with an unlimited number of elements, is specified by the empty square brackets: [] and will be a one-dimensional array.

InitialValue - an expression, specifying the initial value and defining the data type for all of the elements in the array
The value can be a numerical, string, or true/false expression; the type of the expression defines the data type.

DataN - an optional parameter; specifies the Data Number of the data series the array is to be tied to
If this parameter is not specified, the array will be tied to the default data series.

Examples
Declare Length and SFactor as 9-element one-dimensional numerical arrays with data elements' initial values of 0:

Array:
Length[8](0),
SFactor[8](0);



Declare Max_Price as a 24-element by 60-element two-dimensional numerical array, updated on every tick, tied to the series with Data #2, and with data elements' initial values equal to the value of Close function:

Array:IntraBarPersist Max_Price[23,59](Close,Data2);


Declare Highs2 as a dynamic numerical array with data elements' initial values of 0:

Array:Highs2[](0);





source: EasyLanguage manual

Last edited by Tams; 04-20-2009 at 09:32 AM.
Tams is offline  
Reply With Quote
The Following 6 Users Say Thank You to Tams For This Useful Post:
aaa (04-25-2009), momentom (04-20-2009), sezor (04-17-2011), Soultrader (04-20-2009), TIKITRADER (11-01-2009), ValueTrader (11-07-2011)
Old 04-20-2009, 09:11 AM   #2

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 4,052
Ignore this user

Thanks: 2,275
Thanked 1,661 Times in 1,010 Posts

Re: Array (EasyLanguage)

a tutorial on Array:
http://www.markplex.com/tutorial7.php
Tams is offline  
Reply With Quote
The Following 4 Users Say Thank You to Tams For This Useful Post:
aaa (04-26-2009), momentom (04-20-2009), Soultrader (04-20-2009), TIKITRADER (11-01-2009)
Old 04-22-2009, 02:38 PM   #3

Join Date: Jan 2009
Location: jk
Posts: 1
Ignore this user

Thanks: 0
Thanked 1 Time in 1 Post

Re: Array (EasyLanguage)

https://www.tradestation.com/wiki/di...tanding+Arrays
acustik is offline  
Reply With Quote
The Following User Says Thank You to acustik For This Useful Post:
aaa (04-26-2009)
Old 04-22-2009, 10:43 PM   #4

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 4,052
Ignore this user

Thanks: 2,275
Thanked 1,661 Times in 1,010 Posts

Re: Array (EasyLanguage)

Quote:
Originally Posted by acustik »

sorry... not everybody has access to the tradestation website,

but many programs use EasyLanguage (or a variant of it).
e.g. MultiCharts, Open E Cry, TradersStudio, just to name a few.

If the article is not too long, can you do a copy+paste?
Tams is offline  
Reply With Quote
Old 04-23-2009, 05:34 AM   #5

Trader333's Avatar

Join Date: May 2008
Location: UK
Posts: 152
Ignore this user

Thanks: 79
Thanked 24 Times in 20 Posts

Re: Array (EasyLanguage)

Here you go:


Paul

Courtesy of tradestation: www.tradestation.com

The Array concept it is actually very simple.
The attempt of this page is to demystify the concept with simple examples. Please feel free to edit as well as to add alternate methods to clarify the content

Think of an array as an Excel spreadsheet, where you have rows and columns.
It is from this approach that the following examples are designed.

* One Dimensional Arrays
* Multi Dimensional Arrays
* Populating Arrays
* Shuffling Array Data
* Sort new field into Array - soon


Incrementing : For Counter = 1 to Array_Size begin... end;
Decrementing : For Counter = Array_Size DownTo 1 begin... end;
One Dimensional ARRAYS

With one dimensional arrays you get one column with X number of rows to query.

Array: myArray [10] (0);

* the [10] defines one column with 10 rows (not to confuse but a 0 row is actually available too to make 11 )
* (0) = Numeric Data
* (Text) = would = String Data could be entered.


Multi-Dimensional Arrays

Multi-Dimensional arrays enable you to store vast amounts of data more similar to a spreadsheet, thus you could add a specific series of data per bar or per condition to back reference for compare.

Warning
More standard is the two dimensioned array, but since you can do more a warning must be stated here in using a three dimensional array
For example 3 dimensioned arrray would be myArray[10,10,10]; You should have your reasons well in order in advanced as improper dimensioning could easy take up too much memory as well as calculations time could be increased exponentially . The conceptualization of a three dimensional Array would be a spreadsheet cell hyperlinking to another completely new spreadsheet. A better example may be a pallet of boxs 10 across, 10 high and 10 deep. It starts getting very complicated at that level.

Two Dimensional Array

Array: myArray [10,10] (0);

the [10,10] defines 10 columns with 10 rows (or not counting the 0 row, 100 field to populate with data)

* (0) = Numeric Data
* (Text) = would = String Data could be entered.


So if you ask for
Value1 = myArray*[6,7]*; then you are looking for column 6, row 7's data.


Populating Arrays

Arrays values hold from bar to bar.
An array can be populated by a hard number as in:
myArray[4] = High;

or by a Counter method that you predefine variable name is arbitrary as long as the value is not higher than the declared dimensional value.

Var: Counter(0);

Counter = Counter +1;
myArray[Counter] = High;


Shuffling Array Data

Shuffling simply moves the first row of an array to the second and so forth leaving the Arrays first row open for a new entry.
Normally this is done in one step or procedure.

Single Dimension Array Shuffle

Array: myArray [10] (0);
Var: myArraySize(10);
Var: Counter1(0);
Var: HoldRow(0), SaveValue(0);
SaveValue = Value1; {your value or caluclation you want arrayed}
For Counter1 = 1 to myArraySize begin
holdRow = myArray[Counter1]; {save the current Value of this row for the next row }
myArray[Counter1] = SaveValue; {pass the newer Value to this row}
SaveValue = holdRow; {pass the old Value of this row for the next loop}


end;

Multi-Dimensioned Array Shuffle

The code below will shuffle a multi-dimensional array. A new row will be inserted in position 1 and roll the remaining rows back one row each.

Array: myArray [100,10] (0);
Var: myArraySize(100);
Array: Save[10](0); {used as holders for the shuffle}
Array: Hold[10](0); {used as holders for the shuffle}

Var: Z(0), X(0); {Using Single Letters as counters}


{Pass your newest set of Values to a one dimensional Array}

If condition1 then begin
{Sample Data}
Hold[1]= Date;
Hold[2]= Time;
Hold[3]= Open;
Hold[4]= High;
Hold[5]= Low;
Hold[6]= Close;
Hold[7]= UpTicks;
Hold[8]= Downticks;
Hold[9]= CurrentBar;
Hold[10]= close -close[1]0;

for Z = 1 to myArraySize begin

For X = 1 to 10 begin Save[X] = myArray [Z,X]; end; {pass Array Row to Save Array variable LOOP}

For X = 1 to 10 begin myArray [Z,X] = Hold[X]; end; {pass Hold Array variables row LOOP}

For X = 1 to 10 begin Hold[X] = Save[X]; end; {pass the SaveArray to Hold Array LOOP}

if Hold[1]= 0 then BREAK; {Get out of main LOOP if passed row /Hold Array is Empty }

end;
end;

Last edited by Trader333; 04-23-2009 at 05:40 AM.
Trader333 is offline  
Reply With Quote
The Following 3 Users Say Thank You to Trader333 For This Useful Post:
aaa (04-25-2009), flyingdutchmen (10-02-2009), Tams (04-23-2009)
Old 04-25-2009, 07:11 AM   #6
aaa

aaa's Avatar

Join Date: Jun 2008
Location: Switzerland
Posts: 466
Ignore this user

Thanks: 243
Thanked 354 Times in 151 Posts

Re: Array (EasyLanguage)

I'm a good gal, I've made my homeworks.

Is it correct ?

Code:
Var:
count(         0 ),
count.end(   2 );

Arrays: 
Line.ID[2](  0 ),
level[2](	0 ),
Color[2]( 0 );

Level[1] = HighD(1);
Level[2] = LowD(1);

Color[1] = blue;
Color[2] = red;

for count = 1 to count.end
begin
	Line.ID[count]  = TL_New( d , t , level[count], d, t , level[count]);
	TL_SetColor(Line.ID, Color[count]);
end;
aaa is offline  
Reply With Quote
Old 04-25-2009, 03:51 PM   #7
aaa

aaa's Avatar

Join Date: Jun 2008
Location: Switzerland
Posts: 466
Ignore this user

Thanks: 243
Thanked 354 Times in 151 Posts

Re: Array (EasyLanguage)

a little correction but the result has a lot of lines

Code:
Var:
count(         0 ),
count.end(   2 );

Arrays: 
Line.ID[2](  0 ),
level[2](	0 ),
Color[2]( 0 );

Level[1] = HighD(1);
Level[2] = LowD(1);

Color[1] = blue;
Color[2] = red;

for count = 1 to count.end
begin
	Line.ID[count] = TL_New( d , t , level[count], d, t , level[count]);
	TL_SetColor(Line.ID[count], Color[count]);
	TL_SetExtRight(Line.ID[count], true );
end;
aaa is offline  
Reply With Quote
Old 04-25-2009, 04:53 PM   #8

Tams's Avatar

Join Date: Sep 2008
Location: Geelong
Posts: 4,052
Ignore this user

Thanks: 2,275
Thanked 1,661 Times in 1,010 Posts

Re: Array (EasyLanguage)

Quote:
Originally Posted by aaa »
a little correction but the result has a lot of lines
wow... good job... you are trying hard.

maybe too hard.
I would have suggested you to start out with one array.
and you added trendline to the code as well !!!
you are taking on multiple challenges at the same time.



anyway, here's my notes:

You have the trendline starting point same as ending point...
ie. the resultant trendline will be a dot.
that's why you don't see anything unless you use the extend right option.

pls see attachment for detail.
Attached Thumbnails
Array (EasyLanguage)-array.jpg  

Last edited by Tams; 04-25-2009 at 04:59 PM.
Tams is offline  
Reply With Quote
The Following User Says Thank You to Tams For This Useful Post:
aaa (04-25-2009)

Reply

Tags
array, easylanguage

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:

Similar Threads
Thread Thread Starter Forum Replies Last Post
Buy at Open with Easylanguage cleon Coding Forum 5 03-02-2011 12:16 PM
Antonio: Please help me on MP for easylanguage nasdaq5048 Market Profile 13 09-23-2010 10:50 AM
Can function in TS8 return array? ImXotep Technical Analysis 5 05-25-2009 03:13 AM
MT4 Indicator Array Problem. ForexSurfr Coding Forum 0 02-16-2009 01:19 PM
Some EasyLanguage Help Please jjthetrader Coding Forum 8 06-02-2008 05:20 PM

All times are GMT -4. The time now is 02:17 AM.
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
2006-2011 Traders Laboratory, All Rights Reserved.