Hammer to inverted Hammer

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #70437 quote
    cgraubner
    Participant
    Junior

    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!:)

    #70440 quote
    robertogozzi
    Moderator
    Master

    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.

    cgraubner and atxeel thanked this post
    #70450 quote
    cgraubner
    Participant
    Junior

    Thank you very much, this is exactly what I was looking for!;)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Hammer to inverted Hammer


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
cgraubner @cgraubner Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by cgraubner
7 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/14/2018
Status: Active
Attachments: No files
Logo Logo
Loading...