Duyck

Matrix functions - JD

Duyck Wizard 已更新   
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 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)
//
版本注释:
.
版本注释:
.
版本注释:
.
版本注释:
.
版本注释:
.
版本注释:
added some extra functions to the library
版本注释:
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!
开源脚本

本着真正的TradingView精神,该脚本的作者将其开源发布,以便交易者可以理解和验证它。为作者喝彩!您可以免费使用它,但在出版物中重复使用此代码受网站规则的约束。 您可以收藏它以在图表上使用。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?