Hi everyone,
could someone please help me to change this code to an inverted hammer?
REM Hammer
c31 = ABS(Min(Close,Open) - High) <= (AverageTrueRange[14](Close)/atrDoji) AND ABS(Max(Close,Open) - High) <= (AverageTrueRange[14](Close)/atrDoji) AND (ABS(Close - Open) < AverageTrueRange[14](Close)/atrDoji) AND (Min(Close,Open) - Low >= AverageTrueRange[14](Close)/atrLongue)
RETURN c31
because this code for an inverted hammer, does not consider inverted hammers with a shadow:
REM Detection of "black gravestone" or "inverted hammer" candlestick formations.
MarteauInverse = close>open AND low=open AND (high-close)>=3*(close-open)
IF MarteauInverse THEN
structure=1
ELSE
structure=0
ENDIF
RETURN structure AS"Gravestone or Inverted Hammer Detection"
Thank you so much!:)
The Inverted Hammer is required to have an upper shadow at least twice the size of the real body (whose color does not matter), while there should be a little o no lower shadow, this is the code (for the lower shadow the percentage can be changed to your likings):
RealBody = abs(close - open)
UpperShadow = high - max(open,close)
LowerShadow = min(open,close) - low
InvertedHammer = (RealBody <= (UpperShadow * 0.5)) AND (LowerShadow <= (RealBody * 0.05))
InvertedHammer will be set to 1 if true, 0 otherwise.
Thank you very much, this is exactly what I was looking for!;)