Hanging Man (CDLHANGINGMAN)
Summary
Single candle with a small real body, a long lower shadow, and little/no upper shadow, sitting at or near the highs of the prior candle. Bearish reversal signal. A hit is a bearish reversal signal (meaningful at the top of an uptrend).
Chart
Chart metadata i
Outputs
outInteger:pattern_bull_bear·zero·negative
Notes
- Does not verify the preceding uptrend that the pattern classically assumes; confirm the trend context yourself.
- Bulkowski's testing found this acts as a bullish continuation 59% of the time — the opposite of the bearish-reversal reading it's named for ("near random") — and it ranks 87th of 103 patterns for post-breakout performance. (thepatternsite.com)
Inputs
inOpen— Open price of each barinHigh— High price of each barinLow— Low price of each barinClose— Close price of each bar
Outputs
outInteger— -100 when detected (always bearish), 0 otherwise. Never emits +100
Output Values
What candlestick values mean: Candlestick Outputs. The function's flags declare which values it can return: rW7.
| Value | Meaning |
|---|---|
| -100 | Hanging Man pattern detected: bearish |
| 0 | No pattern |
Properties
Numerical Stability: Start-Independent
| ☐ Overlap Input |
| ✅ Independent Y-Axis i |
| ✅ Candlestick i |
| ☐ Display Shift |
| ☐ Can Output NaN or ±Inf |
| ☐ Identity at Period 1 |
| ☐ Uses Transcendental |
| ☐ Input Must Be Positive |
Example
C
#include <stdio.h>
#include <ta_libc.h>
int n = 252;
double open[252]; /* your data, oldest first */
double high[252]; /* your data, oldest first */
double low[252]; /* your data, oldest first */
double close[252]; /* your data, oldest first */
int out[252];
int outBegIdx, outNBElement;
TA_Initialize();
TA_CDLHANGINGMAN( 0, n - 1, open, high, low, close, &outBegIdx, &outNBElement, out );
printf( "%d values from bar %d: [%d, ..., %d]\n", outNBElement, outBegIdx, out[0], out[outNBElement - 1] );Rust
use ta_lib::Core;
let open = vec![0.0; 252]; // your data, oldest first
let high = vec![0.0; 252]; // your data, oldest first
let low = vec![0.0; 252]; // your data, oldest first
let close = vec![0.0; 252]; // your data, oldest first
let mut out = vec![0i32; 252];
let core = Core::new();
let range = core.cdlhangingman(0, open.len() - 1, &open, &high, &low, &close, &mut out)?;
println!("{} values from bar {}: [{}, ..., {}]", range.count, range.beg_idx, out[0], out[range.count - 1]);Java
import io.github.talib.Core;
import io.github.talib.OutRange;
import java.util.Locale;
double[] open = new double[252]; // your data, oldest first
double[] high = new double[252]; // your data, oldest first
double[] low = new double[252]; // your data, oldest first
double[] close = new double[252]; // your data, oldest first
int[] out = new int[252];
Core core = Core.DEFAULT;
OutRange r = core.cdlhangingman(0, open.length - 1, open, high, low, close, out);
System.out.printf(Locale.ROOT, "%d values from bar %d: [%d, ..., %d]%n", r.count(), r.begIdx(), out[0], out[r.count() - 1]);C#
using System;
using TALib;
var open = new double[252]; // your data, oldest first
var high = new double[252]; // your data, oldest first
var low = new double[252]; // your data, oldest first
var close = new double[252]; // your data, oldest first
var outInteger = new int[252];
var core = Core.Default;
OutRange r = core.Cdlhangingman(0, open.Length - 1, open, high, low, close, outInteger);
Console.WriteLine(FormattableString.Invariant($"{r.Count} values from bar {r.BegIdx}: [{outInteger[0]}, ..., {outInteger[r.Count - 1]}]"));TypeScript
import { cdlhangingman } from 'ta-lib';
const open = new Float64Array(252); // your data, oldest first
const high = new Float64Array(252); // your data, oldest first
const low = new Float64Array(252); // your data, oldest first
const close = new Float64Array(252); // your data, oldest first
const { begIdx, values } = cdlhangingman({ open, high, low, close });
console.log(values.length + ' values from bar ' + begIdx + ': [' + values[0] + ', ..., ' + values[values.length - 1] + ']');Go
import (
"fmt"
"log"
talib "ta-lib.github.io/go"
)
open := make([]float64, 252) // your data, oldest first
high := make([]float64, 252) // your data, oldest first
low := make([]float64, 252) // your data, oldest first
close := make([]float64, 252) // your data, oldest first
out := make([]int32, 252)
core := talib.NewCore()
r, err := core.CDLHANGINGMAN(0, len(open)-1, open, high, low, close, out)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%d values from bar %d: [%d, ..., %d]\n", r.NBElement, r.BegIdx, out[0], out[r.NBElement-1])Implementation
Added in 0.4.0.
TA-Lib Definition: cdlhangingman.c · cdlhangingman.yaml
| Native | File |
|---|---|
| C | ta_CDLHANGINGMAN.c |
| Rust | cdlhangingman.rs |
| Java | Core_CDLHANGINGMAN.java |
| C# | Core_CDLHANGINGMAN.cs |
| TypeScript | cdlhangingman.ts |
| Go | cdlhangingman.go |
Python: talib.CDLHANGINGMAN, see ta-lib-python.
TA-Lib is also available for R and more using a wrapper.
Aliases
Hanging Man