Candlestick - Hammer

Hello everybody,

I hope you are doing well during the pandemic.
I am looking for an AFL code that effectively can find the Hammer pattern. I appreciate it if you could me in this regard.

Best regards,

Hello @simon,

If you do a search for "candlestick hammer", there're tons of definitions out there. If you're a registered user, the members' area has some interesting code.

1 Like

Thanks for your reply. I appreciate it.

Could you please refer me to some links?

@simon I would suggest you define what you are looking for, ie what is your meaning of "Hammer". But there are many places to find example AmiBroker afl codes. Try the user library first,
And there you will find many "candlestick" codes if you search. Like this one,

Or you could search the internet and in a few seconds find something like this,

Good Luck!


I deeply appreciate your help, thank you very much :heartpulse:

Hello @portfoliobuilder,
I created a new formula and then paste the formula there, but it is full of errors. Please take a look at the below screenshot:


I want to see the patterns on the chart, for example with arrows:
PlotShapes(IIf(Hammer, shapeUpArrow, shapeNone),colorWhite, 0, L, Offset = -15);

How should I find which Hammer is more effective? or the hammer is a bullish or bearish signal?


With a quick look, you should notice that the first line with an error has a comment after it.
If you replace the error line with the following:

doji=abs(C-O) <= (C*smallBodyMaximum) OR (abs(O-C)<=((H-L)*0.1));

you will see that this line works. I did not check the logic. The other error I got was in the commentary. I will leave that one as an exercise for you to fix.

As for which Hammer works best? That you will have to determine. Is the Hammer bullish? Conventional wisdom/interpretation is that a Hammer is bullish. Do the numbers prove it? That is what AmiBroker can do for you... get you the numbers.


@simon the code correction has been pointed out by @snoopy.pa30

You could try backtesting, explorations, chart reviews.

I think you need to develop a trading strategy and then see if that candlestick pattern is of any use in your strategy by using AmiBroker to test your strategy. There are many books and blogs that review these patterns. I myself do not use candlesticks or their patterns, I use bar charts.

This is the only "Hammer" I have found much use for,


Or the much underrated SAHB.

Thank you very much :heartpulse:

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.