kaigouthro

multitype dynamic multi registry with categories 3d matrix

Education
BINANCE:BANDUSDT.P   BAND / TetherUS PERPETUAL CONTRACT

using matrixes, and overloads.. a complete parallel multiregistry, multitype,multikey datastore.
it can use get, set, delete, with as many registries and individual matrixes as the system can handle.

system >
registry
category names
key names for each item
value (( to x/y in value matrix)
value matrix
item in x/y coords

so putting item 'float XXX' with a value of XXX (ohlc..) for category 'ohlc values' into value matrix floats, floats1 for hist... etc.. historical value for the past X num of bars for all 4 values in historical matrixes..

here's an example..

almost done testing..
very powerful tool

anyone with extensive skills who can take a look at it, i'm open for help prepping and finding any optimizations available

as is, it is very very fast..
i believe i can improve though from here.


_ohlcreg      = initkeyregistry(2,2)
_regfloats    = ini_float(2,2)
_hist1_floats = ini_float(2,2)
_colorreg     = ini_color(2,2)

set(_regfloats   ,  _ohlcreg, 'Normal', 'open  ' ,  open  )
set(_regfloats   ,  _ohlcreg, 'Normal', 'high  ' ,  high  )
set(_regfloats   ,  _ohlcreg, 'Normal', 'low   ' ,  low   )
set(_regfloats   ,  _ohlcreg, 'Normal', 'close ' ,  close )
set(_regfloats   ,  _ohlcreg, 'MTF'   , 'open  ' ,  request.security('MSFT', 'D', open  ))
set(_regfloats   ,  _ohlcreg, 'MTF'   , 'high  ' ,  request.security('MSFT', 'D', high  ))
set(_regfloats   ,  _ohlcreg, 'MTF'   , 'low   ' ,  request.security('MSFT', 'D', low   ))
set(_regfloats   ,  _ohlcreg, 'MTF'   , 'close ' ,  request.security('MSFT', 'D', close ))

set(_hist1_floats,  _ohlcreg, 'Normal', 'open  ' ,  open  [1])
set(_hist1_floats,  _ohlcreg, 'Normal', 'high  ' ,  high  [1])
set(_hist1_floats,  _ohlcreg, 'Normal', 'low   ' ,  low   [1])
set(_hist1_floats,  _ohlcreg, 'Normal', 'close ' ,  close [1])
set(_hist1_floats,  _ohlcreg, 'MTF'   , 'open  ' ,  request.security('MSFT', 'D', open [1] ))
set(_hist1_floats,  _ohlcreg, 'MTF'   , 'high  ' ,  request.security('MSFT', 'D', high [1] ))
set(_hist1_floats,  _ohlcreg, 'MTF'   , 'low   ' ,  request.security('MSFT', 'D', low  [1] ))
set(_hist1_floats,  _ohlcreg, 'MTF'   , 'close ' ,  request.security('MSFT', 'D', close[1] ))

// add colors for these specific ones.. if a value is attempted to retrieve
//  but the spot on the value matrix is empty, it will siimple pull a typecast na.
// so these colors show when specidfied.. will have to make a global or a '*' for any'
set(_colorreg    ,  _ohlcreg, 'Normal', 'open  ' ,  color.red   )
set(_colorreg    ,  _ohlcreg, 'Normal', 'high  ' ,  color.green )
set(_colorreg    ,  _ohlcreg, 'Normal', 'low   ' ,  color.blue  )
set(_colorreg    ,  _ohlcreg, 'Normal', 'close ' ,  color.orange)

// ... etc..
// the retrieval now can select along any axis... 
//     which matrix to use
valmatrix = switch input(0)
    0 => _regfloats
    1 => _hist1_floats

///     which group to pull from
_barchoice = input.string('MTF', options = ['Normal','MTF'])

///     which value from that group-.
valuechoice = switch input(1)
    1 => 'open  '
    2 => 'high  '
    3 => 'low   '
    4 => 'close '
    
plot(get(valmatrix,  _ohlcreg, _barchoice, valuechoice ))


plot(get(_regfloats   ,  _ohlcreg, 'Normal', 'open  '), 'Normal open  ' ,
     get(_colorreg    ,  _ohlcreg, 'Normal', 'open  '))
plot(get(_regfloats   ,  _ohlcreg, 'Normal', 'high  '), 'Normal high  ' ,
     get(_colorreg    ,  _ohlcreg, 'Normal', 'high  '))
plot(get(_regfloats   ,  _ohlcreg, 'Normal', 'low   '), 'Normal low   ' ,
     get(_colorreg    ,  _ohlcreg, 'Normal', 'low   '))
plot(get(_regfloats   ,  _ohlcreg, 'Normal', 'close '), 'Normal close ' ,
     get(_colorreg    ,  _ohlcreg, 'Normal', 'close '))
 
Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.