I have closing value of stock, I want to know if it is going in up direction or down direction?
I have current close value , then I can check its previous value, then previous to previous and so on, then just check if current value > previous value > previous value and so on then its uptrend
or current value < previous value < previous value and so on then its downtrend
this can be done, but in real life this is not the case.
stock’s closing value will not be in sequence. Example
if some stock’s closing values are as below
20, 22, 21, 24, 27, 30, 40, 50 –> here it started from 20 and went up to 50 –> uptrend
or 30, 25, 28, 29, 25, 20, 15 –> here it is started from 30 and down till 15 –> downtrend
How can we identify such direction? I am writing my application in C#, is there any way to handle this ? what should be proper data structure I should use to handle this case?