Indicator based on Hieken Ashi

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #143864 quote
    kaq52
    Participant
    Average

    Hi, need support in creating a simple indicator with following criteria:

    If at least one of the last 5 Hieken Ashi candles have body size 20% of its total length, return true.

    Colour of the candle doesn’t matter.

    Thanks a million in advance.

    #143865 quote
    Nicolas
    Keymaster
    Master

    The below code should do the job.

    xClose = (open+high+low+close)/4
    IF BarIndex=0 THEN
    xOpen = open
    xHigh = high
    xLow = low
    ELSe
    xOpen = (xOpen[1] + xClose[1])/2
    xHigh = Max(Max(high, xOpen), xClose)
    xLow = Min(Min(low, xOpen), xClose)
    ENDIF
    
    harange = xhigh-xlow
    habody = abs(xclose-xopen)
    test = summation[5](habody>=.2*harange)>0
    
    return test
    kaq52 thanked this post
    #143866 quote
    kaq52
    Participant
    Average

    Thanks Nicolas.

    #143871 quote
    robertogozzi
    Moderator
    Master

    There you go:

    once xOpen = open
    xClose     = (open + close + high + low) / 4
    if barindex > 0 then
        xOpen  = (xOpen + xClose[1]) / 2
    endif
    xLow       = min(low,min(xClose,xOpen))
    xHigh      = max(high,max(xClose,xOpen))
    xRange     = xHigh - xLow
    xBody      = abs(xClose - xOpen)
    Cond       = xBody >= (xRange * 0.20)    //Body is 20%+ of the range
    Result     = summation[5](Cond)
    RETURN Result AS "Result"

    you asked for “body is 20%”, but his would almost never return a true value, since being exactly 20% is so rare, if not impossible!   So I added >= so that any candle that is equal to or exceeds 20% returns true. Should you want to be returned when the body is <= 20% just replace “>” with “<“.

    The returned values are 0 to 5 (0=none, 1…5=the number of candles that match your criterion). With the indicator properties you may select either a line or a histogram.

    #143872 quote
    robertogozzi
    Moderator
    Master

    I was  writing while Nicolas posted.

    Better two than none!

    You can see two different ways of setting up the HA candlesticks.

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

Indicator based on Hieken Ashi


ProBuilder support

New Reply
Author
author-avatar
kaq52 @kaq52 Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by robertogozzi
5 years, 4 months ago.

Topic Details
Forum: ProBuilder support
Language: English
Started: 09/10/2020
Status: Active
Attachments: No files
Logo Logo
Loading...