Finding the High of a series of bars

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #251834 quote
    Mellstock
    Participant
    New

    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

    #251836 quote
    Iván González
    Moderator
    Master

    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
    JC_Bywan thanked this post
    #251842 quote
    JC_Bywan
    Moderator
    Master

    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
    Iván González thanked this post
    #251932 quote
    Mellstock
    Participant
    New

    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

    #252009 quote
    robertogozzi
    Moderator
    Master

    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
    Iván González thanked this post
    #252087 quote
    Mellstock
    Participant
    New

    I am still trying to get this issue straight.

    Would this work?

    If Abs(countofposition) = 10 Then

    TopLevel = Highest[BarIndex-TradeIndex+1]

    Endif

    #252093 quote
    robertogozzi
    Moderator
    Master

    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
    Mellstock thanked this post
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Finding the High of a series of bars


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Mellstock @mellstock Participant
Summary

This topic contains 6 replies,
has 4 voices, and was last updated by robertogozzi
5 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/26/2025
Status: Active
Attachments: No files
Logo Logo
Loading...