Duyck

Matrix functions - JD

Duyck Wizard Atualizado   
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// The arrays provided in Pinescript are linear 1D strucures that can be seen either as a large vertical stack or
// a horizontal row containing a list of values, colors, bools,..
//
// With the FUNCTIONS in this script the 1D ARRAY LIST can be CONVERTED INTO A 2D MATRIX form
//
//
///////////////////////////////////////////
/// BASIC INFO ON THE MATRIX STRUCTURE: ///
///////////////////////////////////////////
//
// The matrix is set up as an 2D structure and is devided in ROWS and COLUMNS.
// following the standard mathematical notation:
//
// a 3 x 4 matrix = 4 columns
// 0 1 2 3 column index
// 0
// 3 rows 1
// 2
// row
// index
//
// With the use of some purpose-built functions, values can be placed or retrieved in a specific column of a certain row
// this can be done by intuitively using row_nr and column_nr coördinates,
// without having to worry on what exact index of the Pine array this value is located (the functions do these conversions for you)
//
//
// the syntax I propose for the 2D Matrix array has the following structure:
//
// - the array starts with 2 VALUES describing the DIMENSION INFORMATION, (rows, columns)
// these are ignored in the actual calculations and serve as a metadata header (similar to the "location, time,... etc." data that is stored in photo files)
// so the array always carries it's own info about the nr. of rows and columns and doesn't need is seperate "info" file!
//
// To stay consistent with the standard Pinescript (array and ) indexing:
// - indexes for sheets and columns start from 0 (first) and run up to the (total nr of sheets or columns) - 1
// - indexes for rows also start from 0 (most recent, cfr.) and run up to the (total nr of rows) - 1
//
// - this 2 value metadata header is followed by the actual df data
// the actual data array can consist of (100,000 - 2) usable items,
//
// In a theoretical example, you can have a matrix with almost 20,000 rows with each 5 columns of data (eg. open, high, low, close, volume) in it!!!
//
//
///////////////////////////////////
/// SCHEMATIC OF THE STRUCTURE: ///
///////////////////////////////////
//
////// (metadata header with dimensions info)
//
// (0) (1) (array index)
//
Notas de Lançamento:
.
Notas de Lançamento:
.
Notas de Lançamento:
.
Notas de Lançamento:
.
Notas de Lançamento:
.
Notas de Lançamento:
added some extra functions to the library
Notas de Lançamento:
Added the option to build a matrix from a list, using the new array.from() command

NEW FUNCTION
// 2D matrix init function, builds 2D matrix with dimensional metadata in first two values
// the list of matrix elements are omported using array.from()
f_matrix_from_list(_nr_of_rows, _nr_of_columns, _list) =>
//{
_size = int(_nr_of_rows * _nr_of_columns)
_m = array.new_float(_size + 2, 0)
array.set(_m, 0, _nr_of_rows), array.set(_m, 1, _nr_of_columns)
if array.size(_list) <= array.size(_m) - 2
for i = 0 to array.size(_list) - 1
array.set(_m, i + 2, array.get(_list, i))
_m
//}


Allows the martrix to be initiated in the following way:

insert_column_array = f_matrix_from_list(3, 2, array.from(
10, 20,
30, 40,
50, 60))


Gr, JD.

Disclaimer.
I AM NOT A FINANCIAL ADVISOR.
THESE IDEAS ARE NOT ADVICE AND ARE FOR EDUCATION PURPOSES ONLY.
ALWAYS DO YOUR OWN RESEARCH!
JD.

You can contact me for info/access in PM or on Telegram: @jduyck
PLS, DON'T ASK FOR ACCESS IN THE COMMENT SECTION!
Script de código aberto

Dentro do verdadeiro espírito TradingView, o autor deste script publicou ele como um script de código aberto, para que os traders possam compreender e checar ele. Um viva ao autor! Você pode usá-lo gratuitamente, mas a reutilização deste código em uma publicação é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.

Quer usar esse script no gráfico?