How can I pit a variable into HIGEST

Forums ProRealTime English forum ProBuilder support How can I pit a variable into HIGEST

Viewing 13 posts - 1 through 13 (of 13 total)
  • #252105

    I am looking to put an (integer) variable into Highest.

    The code I write keeps failing saying a positive integer value is expected in [variable, CUSTOMCLOSE] even when I use ABS to ensure a positive value.

    All the commented out lines fail.

    What do I need do to be able able to put a variable into HIGHEST?

    Thank you.

    a = 10
    b = Barindex – a

    //TopShelf = Highest[BarIndex – a +1]
    //TopShelf = Highest[ABS(BarIndex – a +1)]

    c = ABS(BarIndex – a +1)
    TopShelf = Highest[c]

    //TopShelf = Highest[a – barindex]
    //Topshelf = Highest[b]
    //Topshelf = Highest[a]
    Return TopShelf

    #252107
    #252109
    JS

    Hi,
    In PRT you cannot use variables, such as BarIndex or IntraDayBarIndex, in functions that work with brackets ([])…
    Only constant integers are accepted…

    2 users thanked author for this post.
    #252110

    Try replacing line 2 with this one:

     

     

    1 user thanked author for this post.
    #252111

    When you never say the highest of WHAT you are looking for, PRT cannot guess it…

     

     

    #252113

    When you never say the highest of WHAT you are looking for, PRT cannot guess it…

    when the data series is not specified, CLOSE is assumed by default, like Rsi, Averages, etc…

     

    1 user thanked author for this post.
    #252116

    Ok. So then the only problem is that you need to avoid negative values or zero as the number of bars over which you are searching.

    For example :

    If barindex > 10 then
    a = highest[barindex – 10]
    endif

    return a

    2 users thanked author for this post.
    #252126

    Thank you for all of your comments. So I canot put an expression in the square brackets and I must tell PRT I want the High.
    I must put an Integer into the square brakets or a variable that is an integer.

    Why does this not work? Same error as before except says High rather than close.

    a = 4
    c=barindex – a
    topShelf = Highest[c](High)
    Return topShelf

    Barindex is an integer, a is an integer.

    There is no fuction I can find in PRT to ensure a variable is an integer, such as INT() in Excel VBA

    #252127

    Why does this not work? Same error as before except says High rather than close.

    a = 4

    c=barindex – a

    Because at the first few bars, for example when barindex = 1 or 2, c has a negative value and this will not be accepted because it makes no sense. You must avoid that.

    1 user thanked author for this post.
    #252128
    JS

    PRT expects a number inside the brackets [] that is non-zero, positive, and an integer…

    When you use barindex, you get an error because barindex can be equal to zero, so [barindex] causes an error…

    In your example, the number inside the brackets can be negative, since barindex can be zero (e.g., barindex - 4 = -4), which is invalid and results in an error…

    To force a number to be an integer, you can use Floor or Ceil

    #252129

    Barindex is always an integer….

    #252141

    So I canot put an expression in the square brackets and I must tell PRT I want the High.

    I must put an Integer into the square brakets or a variable that is an integer.

    There is no fuction I can find in PRT to ensure a variable is an integer, such as INT() in Excel VBA

    PRT does not distinguish between variables and integers. There are only variables which can have any value. When an integer value is required within square brackets, but your variable in the square brackets is for example 9.234, you simply get an error message. With the “floor” or “ceil” or “round” commands you can enforce a variable to have an integer value.

    And yes, you can put an expression into square brackets. For example, you could say the following

    and this will work, because the expression within the square brackets has always a positive and an integer value. It is never negative nor zero.

    #252156

    Thank you to everyone who has replied. I have learned alot from all of the replies.

    Conceptually I am trying to work out the High from a number of bars ago to the current bar.

    The first input I need is Barindex.

    The Second input I need is Barindex – n where n is the number of bars ago I want to calculate the High from.

    a = barindex
    n = 4
    b= barindex – n
    c = a -b

    Topshelf = Highest[c](High)
    Return Topshelf

    This code works.
    I know now I could put an expression in the square brackets.
    I know that Barindex – Barindex -n = n

    However this excercise has helped me get to grips with how PRT handles the Highest (and related functions)
    Ultimately I would like to use barindex – tradindex with Highest and Lowest in the ProOrder software as a platform from where to exits trades incrementally from.

    I know now I can p

    Topshelf =

Viewing 13 posts - 1 through 13 (of 13 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login