MichelT

Data Structure Stack

The script shows a workaround for stack in pine-script via drawings.
There are few restrictions with them:
1. The depth of the stack cannot be more that amount of allowed drawings (about 40 by now)
2. Because the stack shares the space of drawings throughout the whole script, using drawings with the stack must be careful, with handly creating and removing of each drawing, because otherwise pine's garbage collector might break the stack
3. push() and pop() must be called on every bar, because of implementation of functions in pine there are inner serieses, which must be updated on every bar. So wherever you have a setter or getter in the code - it must be called on every bar. But if it's just an update, then you should pass 'false' as a param of the funtion.


And the example of using the stack: if the stack is empty - then fill it and taking by a value per bar till the stack is emty and then fill it again.
Skript med en öppen källkod

I sann TradingView-anda har författaren publicerat detta skript med öppen källkod så att andra handlare kan förstå och verifiera det. Hatten av för författaren! Du kan använda det gratis men återanvändning av den här koden i en publikation regleras av våra ordningsregler. Du kan ange den som favorit för att använda den i ett diagram.

Frånsägelse av ansvar

Informationen och publikationerna är inte avsedda att vara, och utgör inte heller finansiella, investerings-, handels- eller andra typer av råd eller rekommendationer som tillhandahålls eller stöds av TradingView. Läs mer i Användarvillkoren.

Vill du använda det här skriptet i ett diagram?