Period of highest price

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #31538 quote
    S. Sjolander
    Participant
    Junior

    Hi,

    I have been trying to figure out how I can receive the period of the highest price if I consider a look-back period of, lets say 60 days. For example, if the price peaked 26 days ago, I want to receive the integer ’26’.

    Thanks,

    Simon

    #32120 quote
    Nicolas
    Keymaster
    Master

    A solution would be to use a FOR / NEXT loop to find the previous bar that made the highest high in the last X bars.
    You can find an example to build this kind of loop in our online documentation : https://www.prorealcode.com/documentation/for/
    Let me know if you need more support!

    #32179 quote
    S. Sjolander
    Participant
    Junior

    Thanks for the feedback Nicolas,

    This is the FOR-loop I managed to write:

    Value=0
    for i=1 to 30 do
    if (close[i] > close[i-1] and close[i] > close[Value]) then
    Value=i
    else
    Value=Value
    endif
    next
    
    return Value

    I will be using it for the look-back period to determine divergence patterns for OBV, MACD etc.. Although there may surely be several other applications. If anyone has more applicable ideas I am all ears!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

Period of highest price


Platform Support: Charts, Data & Broker Setup

New Reply
Author
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by S. Sjolander
8 years, 10 months ago.

Topic Details
Forum: Platform Support: Charts, Data & Broker Setup
Language: English
Started: 04/09/2017
Status: Active
Attachments: No files
Logo Logo
Loading...