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
JSParticipant
Senior
Hi,
In PRT you cannot use variables, such as BarIndex or IntraDayBarIndex, in functions that work with brackets ([])…
Only constant integers are accepted…
Try replacing line 2 with this one:
b = max(1,Barindex – a)
When you never say the highest of WHAT you are looking for, PRT cannot guess it…
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…
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
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
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.
JSParticipant
Senior
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…
Barindex is always an integer….
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
Pi = 3.14159
BI = barindex
av = average[ceil((BI+1)/Pi)](high)
return av
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.
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 =