Store DEMA Indicator High/Low

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #113086 quote
    Ξ3
    Participant
    Average

    Hi,

    Is there a way to store or calculate the highest / lowest value that an indicator reached for each bar?

    MyIndicator = DEMA[Variable](Close)

    MyIndicatorHi = Highest value that MyIndicator reached during the formation of a particular bar

    MyIndicatorLo = Lowest value that MyIndicator reached during the formation of a particular bar

    Many Thanks.

    #113094 quote
    robertogozzi
    Moderator
    Master

    There yo go:

    MyIndicator   = DEMA[Variable](Close)
    MyIndicatorHi = Highest[variable](MyIndicator)
    MyIndicatorLo = Lowest[variable](MyIndicator)
    #113099 quote
    Ξ3
    Participant
    Average

    Hi Roberto,

    Many thanks for your response but I think my request was not clear enough.

    In your code the Highest function returns the highest CLOSE value in the past “variable” periods.
    What I would like to store/calculate is the highest HIGH/LOW value per bar (so only for 1 period)

    MyIndicatorHi = DEMA[Variable](High) won’t work either as it uses the High value for current and past “variable” periods.
    What I am looking for is some way to use the High (or Low) value for the current bar but the Close value for past “variable” periods.

    A simple 3 period MA would be:
    MyMA = Close + Close[1] + Close[2]
    MyMAHi = High + Close[1] + Close[2]
    MyMALo = Low + Close[1] + Close[2]

    But how to calculate this for an Infinite Impulse Response (IIR) filter with a variable lookback period such as a DEMA is what I am trying to do.

    #113100 quote
    Ξ3
    Participant
    Average

    CORRECTION:

    A simple 3 period MA would be:
    MyMA = (Close + Close[1] + Close[2]) / 3
    MyMAHi = (High + Close[1] + Close[2]) / 3
    MyMALo = (Low + Close[1] + Close[2]) / 3

    #113102 quote
    robertogozzi
    Moderator
    Master

    It’s not possible, when you calculate an average, whatever it is, such as:

    Average[10](close)

    you cannot ask it to use HIGH for just the most recent period.

    You could use

    (Average[10](close) + high) / 2

    but it’s not the same.

    Ξ3 thanked this post
    #113104 quote
    Ξ3
    Participant
    Average

    Thanks for that Roberto. It gave me a new idea…
    Do you perhaps have the ProRealTime code to calculate the DEMA?

    #113106 quote
    Vonasi
    Moderator
    Master

    DEMA is quite simple to calculate:

    p=20
    
    a = exponentialaverage[p](close)
    b = exponentialaverage[p](a)
    mydema = (2*a)-b
    
    return mydema
    Ξ3 thanked this post
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Store DEMA Indicator High/Low


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Ξ3 @cbeukes Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 11/19/2019
Status: Active
Attachments: No files
Logo Logo
Loading...