How can I pit a variable into HIGEST
Forums › ProRealTime English forum › ProBuilder support › How can I pit a variable into HIGEST
- This topic has 12 replies, 4 voices, and was last updated 1 hour ago by
Mellstock.
-
-
10/02/2025 at 3:09 PM #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 TopShelf10/02/2025 at 3:39 PM #25210710/02/2025 at 3:58 PM #25210910/02/2025 at 3:58 PM #252110Try replacing line 2 with this one:
1b = max(1,Barindex – a)1 user thanked author for this post.
10/02/2025 at 4:12 PM #25211110/02/2025 at 4:20 PM #252113When 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.
10/02/2025 at 4:26 PM #252116Ok. 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]
endifreturn a
2 users thanked author for this post.
10/02/2025 at 10:04 PM #252126Thank 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 topShelfBarindex 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
10/02/2025 at 11:29 PM #252127Why 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.
10/02/2025 at 11:30 PM #252128PRT expects a number inside the brackets
[]
that is non-zero, positive, and an integer…When you use
barindex
, you get an error becausebarindex
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
orCeil
…10/03/2025 at 5:50 AM #25212910/03/2025 at 4:51 PM #252141So 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
1234567Pi = 3.14159BI = barindexav = average[ceil((BI+1)/Pi)](high)return avand this will work, because the expression within the square brackets has always a positive and an integer value. It is never negative nor zero.
10/04/2025 at 11:25 AM #252156Thank 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 -bTopshelf = Highest[c](High)
Return TopshelfThis code works.
I know now I could put an expression in the square brackets.
I know that Barindex – Barindex -n = nHowever 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 =
-
AuthorPosts
Find exclusive trading pro-tools on