Store DEMA Indicator High/Low

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

    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
    robertogozzirobertogozzi
    Moderator
    Legend

    There yo go:

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

    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Ξ3
    Participant
    Senior

    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
    robertogozzirobertogozzi
    Moderator
    Legend

    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Ξ3
    Participant
    Senior

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

    #113106 quote
    VonasiVonasi
    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.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

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 VonasiVonasi
6 years, 10 months ago.

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