How do. I find the High of a series of bars.
say countofpostions = 10
How can I find the Maximum (or highest) of the High of the bar when countofpositions became 10 and the High of the current bar (and subsequent bar when that happens).
Thank you
You can use the HIGHEST function in ProBuilder to find the maximum of the last N bars.
In your case, if you want to get the highest value of the High over the last 10 bars, you can do it like this:
countofpositions = 10
maxHigh = HIGHEST[countofpositions](High)
if maxHigh = high then
DRAWTEXT("MaxHigh = #maxHigh#", BarIndex, High)
endif
return maxHigh
Hi,
the request is slightly ambiguous because you don’t use the same spelling for countofposition as an existing proorder keyword, so it might give the impression you meant it as a variable for the series length, but it could be you really meant “when my position reaches size 10”:
COUNTOFPOSITION
so, assuming the latter and using countofposition as the above proorder command counting your number of contracts/shares (so spelling with no “s”, and adding the missing “i”) rather than a personal variable, then you could try this to find highest value of both highs, regardless of how long it took between reaching size 10 and current bar (NB: this piece of code doesn’t extrapolate on your behalf what value to give to “myhighest” after countofposition is not 10 anymore):
if countofposition[1]<countofposition AND countofposition=10 then
highwhen10=high
elsif countofposition<>10 then
highwhen10=0
endif
if countofposition=10 then
myhighest= max(highwhen10,high)
endif
Thanks for replies. The situation is for when countposition equals a certain number.
Does TradeIndex(1) help here.
Would
If Countposition = 10 Then
MaxH = Highest[TradeIndex(1)-Barindex +1]
Endif
work?
Thank You
Maybe this one?
When10bar = 0
When10Hi = 0
NextBar = 0
NextHi = 0
CurrentBar = 0
CurrentHi = high
myPos = CountOfPosition
FOR i = 0 TO BarIndex - 1
IF myPos[i] = 10 THEN
When10bar = i
When10Hi = high[i]
NextBar = i - 1
NextHi = high[NextBar]
break
ENDIF
ENDIF
NEXT
graph When10bar
graph When10Hi
graph NextBar
graph NextHi
graph CurrentBar
graph CurrentHi
I am still trying to get this issue straight.
Would this work?
If Abs(countofposition) = 10 Then
TopLevel = Highest[BarIndex-TradeIndex+1]
Endif
Yes, that seems correct.
You can easily check it by GRAPHing TopLevel to verify if it’s the correct value when the last entry occurred:
GRAPH TopLevel //or GRAPHONPRICE TopLevel