Help to find maximum between 2 periods

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #30624 quote
    RAFFAELE
    Participant
    New

    Good afternoon everybody .
    I’m looking for a code to calculate a maximum or a minimum in a particular period.
    For example, the maximum from 45 bar to 126 ….etc
    Can someone help me….?

    #30647 quote
    AutoStrategist
    Participant
    Veteran

    Its something I often need to do, I do it like this as it appears that Highest only takes a single parameter.
    Be interested to find out from someone if there is a more elegant way to do this.

    
    StartBar = 'YourStartValue'
    EndBar = 'YourEndValue'
    
    HighValue = 0
    for Counter = StartBar to EndBar
    HighValue = max(HighValue,close[Counter])
    next
    #30728 quote
    JC_Bywan
    Moderator
    Master

    Hi Raffaele and Autostrategist,


    @Autostrategist
    , you’re right in saying highest only takes one parameter, but it also accepts to look at previous values of itself, which, even if it’s not a “pure” second parameter like “start, finish”, allows for the kind of solution I think you’re asking for without a for to/next loop: assuming lead post of the topic was counting from current bar towards the left until bars 45 and 126, we can look at what was the value at 45th past candle of highest during an interval of (126-45+1)=82 candles with the following syntax:

    Highvalue=highest[82](close)[45]

    (edit: example here done with “close”, but also works with “high” instead of “close” when purpose is to find highest high of interval rather than highest close)

    AutoStrategist, Nicolas and Bel thanked this post
    #30742 quote
    AutoStrategist
    Participant
    Veteran
    Thanks Noobywan I was hoping when I responded that there was  a better way than mine. My question though is how a user finds this information, I may have overlooked it but I don’t see this in the documentation or am I just looking in the wrong place?  Here is another example that Nicholas wrote, where can I find the list of all the parameters that summation or any other function accepts?

    bearpattern = summation[Xcandlesticks](close<open)=Xcandlesticks

    #30769 quote
    robertogozzi
    Moderator
    Master
    This forum may help a lot, but I urge PRT to improve documentation, since it’s poorly made, with few examples.
    #30798 quote
    JC_Bywan
    Moderator
    Master
    Well I wish I could help more with finding this in the doc, but it’s not something I found there, it’s just a syntax usage I explored by “trial and error”, when I first wondered a while ago if adding [n] to call value of n’th previous candle could work when added to, not just easy terms (like close[n] as they show bottom of page 7 of pro-builder manual), but also to already complex terms like highest[a](variable) or exponentialaverage[b](blabla) or basically anything having already other stuff in various brackets… turns out it does, but I can’t say I saw it somewhere in the doc, can’t even say if it works only for some and not for others, I haven’t tried all existing combinations. So I can only share my own findings, but I can’t point to a specific part of the manual for this, other than page 7 and its (too) basic examples… and I’m not saying it’ not in there somewhere either, maybe it is and I missed it… For all of us wanting doc improvements, best way is to express this wish in Nicolas’ existing wish list: https://www.prorealcode.com/topic/centralization-of-queries-and-suggestions-on-prorealtime/ and/or perhaps the PRT suggestions contact form for next version 10.4 too: https://www.prorealtime.com/en/contact?suggestion=1
    AutoStrategist thanked this post
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.

Help to find maximum between 2 periods


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
RAFFAELE @raffaele Participant
Summary

This topic contains 5 replies,
has 4 voices, and was last updated by JC_Bywan
8 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/01/2017
Status: Active
Attachments: No files
Logo Logo
Loading...