It's a helpful toolset while designing UDT's as it remains flexible, this helps in not having to remap an entire script while tinkering. Set an object up, and add as man properties as yyou wish. a property can be one of any pine built in types. so a single object can contain sa, ohlc each with a color, a float, an assigned int and those 4 props each have 3 sub-assigned values. as in demo, the alternating table object has 2 different tables it's a pseudo more complex wa to create our own flexible version of a UDT, but that will not ~break~ on library updates so you can update awa without fear, as this libb will no change saving ou the hassle of creating UDT's that continually change.
set(dict, _object, _prop, _item) Add/Updates item to storage. Autoselects subclass dictionary on set Parameters: dict: (dictionary) dict.type subdictionary (req for overload) _object: (string) object name _prop _item: (<any>) item to set Returns: item item wwith column/row
get(typedict, _object, _prop) Get item by object name and property (string) Parameters: typedict: (<any>dict) dict.type subdictionary (req for overload) _object: (string) object name _prop Returns: <type> item from storage
remove(typedict, _object, _prop) Remove a specific property from an object Parameters: typedict: (<any>dict) dict.type subdictionary (req for overload) _object: (string) object name _prop Returns: <type> item from storage
delete(_dict, _object) Remove a complete Object and all props Parameters: _dict _object: (string) object name Returns: <type> item from storage
delete(_dict, _index) Parameters: _dict _index
wipe(_dict, _object, _prop) Remove Property slot for all 10 item types Parameters: _dict: (dictionary) The full dictionary item _object: (string) object name _prop Returns: <type> item from storage
wipe(_dict, _index) Parameters: _dict _index
init(_Objlim, _Proplim) Create New Dictionary ready to use (9999 size limit - (_objlim +_Proplim) for row/column 0) # Full dictionary with all types > start with this Parameters: _Objlim: (int) maximum objects (think horizontal) _Proplim: (int) maximum properties per obj (vertical) Returns: dictionary typoe object
In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in a publication is governed by House rules.
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.