How I can write a code for a "Hammer" candlestick pattern?

 

I'm trying to make a robot that can recognize when a "Hammer" shows up on the chart.

So far I have a way to command MetaTrader to look for when the last candle's Low[] is lower than the last 3 candles:

 if(Low[1] < Low[2]&& Low[1] < Low[3] && Low[1] < Low[4])

 I also have a way to tell Metatrader to look for a candle whose body is within range of the previous candle:

if(Open[1] < High[2] && Close[1] > Low[2]);

 

Question: How can I better describe the exact structure of the Hammer candlestick, such as the body being closer to the top of the candle, and the "tail" being greater than the length of the body?

I am also open to any suggestions on more rules to define this candle and a code to communicate what I can see on the charts to MetaTrader.

 
AlmightyAnalyst:

I'm trying to make a robot that can recognize when a "Hammer" shows up on the chart.


Have you had a look through the codebase? There are quite a few candlestick pattern recognition examples in there which might provide some inspiration.
 
Indicators: PinBar
Indicators: PinBar
  • www.mql5.com
Shows levels specified by the pattern for the open price and stop-loss. - - Category: articles, library comments
 
Filter:
Have you had a look through the codebase? There are quite a few candlestick pattern recognition examples in there which might provide some inspiration.
Thank you, I'm going to look through and see what I can find.
 
Thanks so much, I appreciate these links. I'm going to check them out right now.
 
TIMisthebest:

see this, maybe help to find your way:

The "Pinbar" indicator does exactly what I am looking for. I noticed that you had one for MT5 and MT4 as well. I am currently using MT4. Is there is download file for an MT4 version? I did not see it on any of the links.