Ceiling line not working with minimum

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #162558 quote
    gfx
    Participant
    Average

    Hi,

    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.

     

    ema = Average[20](close)
    
    IF ema < ema[1] THEN
    ceils = Highest[20](high)
    ELSE
    ceils = ceils[1]
    ENDIF
    
    Return ceils
    

    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.

    ema = Average[20](close)
    
    IF ema < ema[1] THEN
    ceils = Min(ceils[1], Highest[20](high))
    ELSE
    ceils = ceils[1]
    ENDIF
    
    Return ceils
    

    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 …

    ema = Average[20](close)
    
    once ceils = 1000000000000000
    
    IF ema < ema[1] THEN
    k = Min(ceils[1], Highest[20](high))
    ceils = k
    ELSE
    ceils = ceils[1]
    ENDIF
    
    Return ceils

    Ceiling line still not drawn on chart 🙂

    Any idea why ?

    Thks.

    gfx

    c1.jpg c1.jpg
    #162570 quote
    Vonasi
    Moderator
    Master

    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.

    #162571 quote
    Vonasi
    Moderator
    Master

    Have you tried enclosing your code in:

    if barindex >= 20 then
    ....
    endif
    #162572 quote
    robertogozzi
    Moderator
    Master

    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):

    IF BarIndex > 20 then
    ema = Average[20](close)
    once ceils = Highest[20](high)
    IF ema < ema[1] THEN
    ceils = Min(ceils, Highest[20](high))
    ENDIF
    endif
    Return ceils

    Third example is like the second one:

    if barindex > 20 then
    ema = Average[20](close)
     
    once ceils = Highest[20](high)//1000000000000000
     
    IF ema < ema[1] THEN
    k = Min(ceils, Highest[20](high))
    ceils = k
    endif
    endif 
    Return ceils
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Ceiling line not working with minimum


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
gfx @gfx Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 02/24/2021
Status: Active
Attachments: 1 files
Logo Logo
Loading...