Surely the definition of discretionary is that it isn't systematic, and therefore can't be programmed?
Having said that I suppose you could try training a neural network or similar to recognise chart patterns; essentially get thousands of charts, hand label them with the sort of feature you...