using "setup" probability as a way to determine if trade should be entered or not

 
Hi guys! I'm trying to code a simple probability based EA. 

Now thing is, I don't have code based of this at the moment, but really am looking at any tutorial/article that deals with this, since I dont know where to start. If you do know of any, please share it here.

For example, I want to check the probability of a simple candle pattern (say bulish engulfing) based of the last x (or say 10) occurences, and if probability of success is >50% enter on next occurence of the pattern.

Now thing is, it is easy to identify from history, but how do you see the success/failure of an instance without trading it? - any advice on how to approach this would be highly appreciated! 

Kind Regards