User Guide – Hammer, Doji Candlestick Detector
The following release notes are for the Metatrader MT4 Hammer, Doji Candlestick Detector.
Quick Start
Drag and drop the indicator onto the required chart. The default settings are only a guide. You will need to tune these to your market and timeframe. The detections are marked on the chart in red/green for manual trading, however you can adjust these colors as required. The indicator outputs numerical values (see below) and these are displayed in the chart’s lower window.

For lower timeframe charts (M1-M30) use a smaller point setting for the “shadow threshold”. This can be increased for longer timeframes.
Input Settings
Input setting | Comment |
---|---|
Trend confirmation bars | The candle must break a high/low of at least this many bars |
Shadow/body ratio | The ratio of the candle shadow to body – Set bigger for small body vs long shadow |
Body position | Zero means body must position exactly at end of shadow. When 1, body can be centralized on the shadow |
Width of hammer display on chart | Display setting |
Shadow threshold (in points) | The shadow must be at least this many points |
Detection tolerance (in points) | Add a tolerance to include borderline cases |
Detect hammer types | Choose candle (hammer) type: Any (0), Normal (1), Inverted (2) |
Accumulator width (bars) | Consider hammer groupings over this many bars to produce accumulator line |
Accumulator smoothing period (bars) | Smoothing factor for accumulator line |
Color for buy signals | Color setting |
Color for sell signals | Color setting |
Send terminal alerts? | Alert on any hammer events |
Send email alerts? | Send an email on hammer events (through Metatrader terminal) |
Send mobile push notifications? | Send text alert on hammer events (through Metatrader terminal) |
Min. interval between alerts (seconds) | Alert no more than this many seconds (prevents rapid alerts) |
Outputs
Signal/Mode | Name | Description |
---|---|---|
0 | Acc | Accumulator line (see below) |
1 | Buy hammer | Negative value indicating buy hammer strength (∝ ln shadow size) |
2 | Sell hammer | Positive value indicating sell hammer strength (∝ ln shadow size) |
The indicator has both graphical and numerical output. The numerical output lets you use the system as an input to an expert advisor or other signalling software. The indicator produces a numerical output at each pattern, with positive indicating bearish reversals and minus values indicting bullish reversals. The absolute value is a measure of the strength (or confidence).
- Bullish – Hammer/inverted hammer
- Bearish – Shooting star/hanging man
- Neutral – doji
Using the Indicator
The indicator is designed to detect hammers, shooting stars, doji, hanging men and inverted hammers. The setup will allow you to filter the weaker or more ambiguous cases out to leave the stronger trading signals. To filter the signals the three key settings are as follows:
- Shadow length
- Shadow/body ratio
- Body position
These settings will control the types of patterns that are detected and displayed on the chart and those which are ignored.
Confirm bars: The indicator will examine a certain number of bars preceding the candle. This is defined in the “confirm bars” parameter. This is necessary to filter out weak and false signals and to analyze the direction of the trend. A lower setting will result in more signals but there will likely be more false positives. A higher setting will produce fewer but more viable signals.
Figure 2 shows a bullish reversal signal. In this example I used the following settings:
- Shadow length=45
- Shadow/body ratio=5
- Body position=0.25
- Confirm bars=25

As shown in Figure 2 several weak hammers (doji), which were in fact fake signals, are filtered out.

Figure 3 shows an example of a bearish reversal pattern using the same settings. A fake hammer signal is marked on the chart, and this is correctly filtered out.
Accumulator
The accumulator is a type of oscillator. This signal can be used as an alternative measure of momentum similar to MACD, RSI or OSMA. The difference though is that it works the appearance of candle patterns. It can indicate an overbought/oversold market.
- Each bearish signal increments the line by 1.
- Each bullish signal decrements the line by 1.
The signal rises when there are a series of bearish patterns which usually happens in an up trend. The signal falls when there are a series of bullish patterns which are usually seen in a down trend.
The figures below show examples of how this works.


The counting is over the number of bars set in the parameters (Accumulator width). The output can also be smoothed as required from the setting Accumulator smoothing period (bars). This signal will lag depending on how much smoothing is applied and how wide the counting window is.
The idea behind this is that the market is reaching “overbought” when you have a series of bearish (reversal) patterns without a correction. These usually occur in an upward trend. The accumulator line will increase in this situation because each bearish flag adds to the signal.
In a down trend the reverse happens. Each bullish pattern decreases the signal. So a series of bullish flags without a correction will push the accumulator line downwards indicating that the market is reaching an oversold state.
This can be interpreted as follows:
- High values indicate a dominance of bearish reversals.
- Low values indicate a dominance of bullish reversals.
The greater the absolute value of the accumulator line, the more extreme the market position is considered to be. The direction and steepness of the slope is a measure of momentum.
The counting for the accumulator occurs over a fixed time period (in bars). This should be set according to the required scale. A wider scale will give a broader, but more complete view. A narrower scale will give a more precise but noisy view.
When trading on Japanese candlestick signals the accumulator can be useful. It gives an idea of trend strength and the likelihood that a pattern will actually result in a reversal or be a fake signal. Extreme values in the accumulator suggest that more of the signals have been fake and have not preceded a reversal on the scale being examined. It also suggest that the market is reaching a more extreme position in being either overbought or oversold. For an example see the figures above.
Point sizes
If you see no output from the indicator it could be due to the point size parameter. One of the inputs is the “Shadow threshold (in points)”. Since brokers use different definitions for point sizes you will need to change this as required. This default value is 150 points (15 pips) and this will work for most accounts. If your broker uses a larger point size (e.g. some micro accounts) then change this value to 15 points.
A smaller value may be needed for lower time frames.
The detection tolerance (in points) : Patterns which don’t break lows/highs are rejected when this is set to zero. Increase this value to accept cases that are close to but not above the threshold.
The shadow threshold (in points)
This is a cut off threshold for the total size of the candle. It is the total length (H – L) for the candle.
The filter works as follows :
- (H – L) > [shadow threshold]
When this condition is true the pattern is displayed otherwise it is ignored. This number is in points.
Hammer types
The indicator detects and classifies two different pattern/hammer types. The input setting “Detect hammer types” lets you choose from:
- Hammer/shooting star patterns only
- Inverted hammer/hanging man patterns only
- Any pattern – will detect both types
Further Resources
Video: https://www.youtube.com/watch?v=1GMtdFL9itg
https://forexop.com/strategy/hammer/
Return to the product page.