Let’s take an ema and compare current value with its previous value.
As long as it goes down, slode negative, we draw a ceiling on top of price with highest high of last 20 bars.
1
2
3
4
5
6
7
8
9
ema=Average[20](close)
IFema<ema[1]THEN
ceils=Highest[20](high)
ELSE
ceils=ceils[1]
ENDIF
Returnceils
Result in attached file.
It looks great until the slope turns positive for a few candles, and then negative again, whereas during these few candles the highhest high over the 20 last high has increased.
The orange line turns blue. But I don’t want the ceiling value to increase.
So I decide, when the slope is negative, to draw as ceiling the minimum value beetween the previous ceilling and the highest high.
1
2
3
4
5
6
7
8
9
ema=Average[20](close)
IFema<ema[1]THEN
ceils=Min(ceils[1],Highest[20](high))
ELSE
ceils=ceils[1]
ENDIF
Returnceils
When I validate the indicator, no ceiling line is drawn on the chart.
I don’t undestrand why …
I tried to initialise with a high value, and/or use a temporary variable to calculate the min …
gfx – Once again this is an indicator coding question and not a platform issue. That is the second one tonight posted in the wrong place. Please try to understand which forums are for which subjects. I moved your topic….again.
Post your topic in the correct forum:
_ ProRealTime Platform Support: only platform related issues.
_ ProOrder: only strategy topics.
_ ProBuilder: only indicator topics.
_ ProScreener: only screener topics
_ General Discussion: any other topics.
_ Welcome New Members: for new forum members to introduce themselves.
In the first two examples, lines 5 and 6 can be removed.
Example 1 works fine. Please post instrument, TF, date and time of the candle where it plots incorrectly.
If you replace your second example with this one, it’lll work, but due to MIN() the indicator is quite BELOW the current price so you’ll have to shrink the chart slightly (and use 10K units):
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok