Ξ3Participant
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.
There yo go:
MyIndicator = DEMA[Variable](Close)
MyIndicatorHi = Highest[variable](MyIndicator)
MyIndicatorLo = Lowest[variable](MyIndicator)
Ξ3Participant
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.
Ξ3Participant
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
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.
Ξ3Participant
Average
Thanks for that Roberto. It gave me a new idea…
Do you perhaps have the ProRealTime code to calculate the DEMA?
DEMA is quite simple to calculate:
p=20
a = exponentialaverage[p](close)
b = exponentialaverage[p](a)
mydema = (2*a)-b
return mydema