Indicator from average

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #161212 quote
    AnouarAnouar
    Participant
    New

    Hi community,

    I want to create a varible that would be used as length of average window

    LengthWindow = round(average[20](close) )
    RetIndicator = average[LengthWindow](close)
    return RetIndicator

    Such solution wouldnt work because LengthWindow is not defined for the first 20 numbers. The program will yield an error: A positive integer filed is expected with average

    A first solution would be to fill the LengthWindow with any nunber for the first 20 elements and things will work

    if BarIndex < 20 then 
        LengthWindow = 1
    else
        LengthWindow = average[20](close)
    endif
    RetIndicator = average[LengthWindow](close) 
    return RetIndicator 
    

    This solution does not work as well

     

    Any idea please

    Many thanks

    Anouar

    #161219 quote
    VonasiVonasi
    Moderator
    Master

    Anouar – Welcome to the forums. I moved your topic to the ProBuilder forum as the ‘Welcome New Members’ forum is not the place for it. Please try to post any future topics in the correct place.

    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.

    #161220 quote
    VonasiVonasi
    Moderator
    Master

    Try this:

    if barindex >= 20 then
    LengthWindow = round(average[20](close) )
    RetIndicator = average[LengthWindow](close)
    endif
    
    return RetIndicator
    #161349 quote
    AnouarAnouar
    Participant
    New

    Thank You very much for Answer,

    It worked for this example, for some reason it still does not work for the next example:

    HVWindow=100
    if (BarIndex > HVWindow)    then
    ProxyWindow = historicvolatility[HVWindow](close)
    Window = round(ProxyWindow)
    RetIndicator=average[Window](close)
    
    endif
    
    return RetIndicator

    Do you have any idea please?

     

    Many thanks,

    Anouar

    #161351 quote
    VonasiVonasi
    Moderator
    Master

    Because the Historic Volatility indicator can return values below 0.5 and when any value below 0.5 is rounded this equals zero and zero is not a positive integer.

    #164928 quote
    AnouarAnouar
    Participant
    New

    Worked, Thank you

Viewing 6 posts - 1 through 6 (of 6 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

Indicator from average


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by AnouarAnouar
5 years, 6 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 02/12/2021
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...