I am sure the answer to this question is simple, but I can't find it.

How do I ask the algorithm to count the total number of certain indicator (certain candlestick pattern) or trades that happen when algorithm is done running. I am aware that console displays that information for us. But how can I get it (capture it) myself so I could use this number for my further calculations?