TradingView
marspumpkin
20 Ara 2021 05:38

hashmaps 

US SPX 500OANDA

Açıklama

A simple hashmap implementation for pinescript.

It gets your string array and transforms it into a hashmap.
Before using it you need to initialize your array with the size you need for your specific case since the size is not dynamic.

To use it, first you need to import it the following way:
> import marspumpkin/hashmaps/1

Then, initialize your array with the size needed for your specific case:
> hashmap = array.new_string(10000)

After that you can call:
> hashmaps.put() and hashmaps.get()

Passing in the array(hashmap), key and value.

I hope this helps you in your pinescript journey.

Sürüm Notları

v2 - supports PSONs as value

Sürüm Notları

v3 added contains()

Sürüm Notları

v4 added new put() functions and get_float() get_int() get_bool()

Sürüm Notları

v5 added remove()
Yorumlar
Trendoscope
Good job :)
marspumpkin
@HeWhoMustNotBeNamed, thank you, my lord!
RicardoSantos
thank you for improving pinescript for all :)
marspumpkin
@RicardoSantos, thank you! there is still room for improvement/optimization but it's a start :)
DaJackal
It's a great library, I love this. I have a problem with it though: it returns series string when I do a get, while I need a simple string for a request.security call. Do you guys know how to workaround this or make it work so I always get back a simple string?
marspumpkin
@DaJackal, I'm afraid this isn't possible in Pine at the moment. Currently there is no way to cast 'series string' to a 'simple string' and if we are working with arrays it will always be a 'series string' :(
OgahTerkenal
Thank you for this, is it possible to create a SHA-256 out of this?

For example plotting 32 value of int for each byte:
plot(series=0, title="H0")
plot(series=1, title="H1")
... and so on until
plot(series=31, title="H31")

And after that sending inside alert like:
{"key":
plot("H1"),
plot("H2"),
plot("H3"),
... and so on until
plot("H31")
}
* sorry, I can't use array brackets in this comment

So for each int received in the other side could be converted back to hex string and concatenated to form the full SHA-256 hash.
marspumpkin
@OgahTerkenal, Thank you for the comment. I'm sorry, I don't understand what you mean? My intention with this library was to create a hashmap as in the data structure. You want it to generate SHA-256?
Daha Fazla