user3848207
user3848207

Reputation: 4977

Create array of same value in Amibroker

I would like to create an array of same value in Amibroker. The array should look like this;

Arr_fix[0] = 80;
Arr_fix[1] = 80;
Arr_fix[2] = 80;
...
Arr_fix[n] = 80; //n is LAST_VALUE of array

Upvotes: 1

Views: 2639

Answers (1)

fxshrat
fxshrat

Reputation: 89

You can simply write

var = 80;

Plot( var, "var", colorDefault, styleLine );

and "80" will be there on entire array length of a symbol.

On the other hand if you want to create a custom array then do

n = ...; // rownum value

mat = Matrix( n, 1 );

for( i = 0; i < n; i++ )
    mat[i][0] = 80;

printf( MxToString( mat ) );

or shorter

mat = Matrix( n, 1, 80 );

n could be Barcount too.

You could also convert from string to matrix:

matstring = "[80;80;80;80]";

mat = MxFromString( matstring );

printf( MxToString( mat ) );

In order to convert Matrix block(s) to 1-dim array use MxGetBlock function.

Check AFL function reference ti get details of each function http://www.amibroker.com/guide/AFL.html

Upvotes: 3

Related Questions