maximum angle in lookback period.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #75942 quote
    Real ProReal Pro
    Participant
    Average

    Hiya,

    I’d like to compare today’s high to each of the highs in a lookback range of 20 bars.  Then divide that number by the bars since that high occured, in order to find the highest angle possible between today’s high and a single high in the lookback period.  Could I have some clues where to start please?

    #75954 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Angles/Slopes are impossible to be measured, this has been extensively discussed here and elsewhere. Some useful links:

    https://www.prorealcode.com/topic/ema-45-degres-uptrend/

    https://www.prorealcode.com/topic/indicator-for-inclination-of-moving-average/

    https://www.prorealcode.com/topic/calculating-the-angle-linear-regression-of-a-line/

    Anyway, to retrieve the BarIndex ID of a bar you can only use loops, since there’s no function returning that info, as of this version of PRT:

    FOR i = 0 TO 19                  //20 bars lookback
       IF high[i] > high[i+1] THEN   //put here anything you like to check
          .
          .
       ENDIF
    NEXT
    Real Pro thanked this post
    #75956 quote
    GraHalGraHal
    Participant
    Master

    in order to find the highest angle possible between today’s high and a single high in the lookback period

    I guess if you had said … to get a measure of the rate of change between today’s high and a single high in the lookback period ... may be less confusing and might get you the code you need? 🙂

    Real Pro thanked this post
    #76274 quote
    Real ProReal Pro
    Participant
    Average

    Thanks for the help Robert and Grahal.

    Grahal, that’s an excellent idea.  Am I geting closer with the following?

    FOR i = 0 TO 20                  //20 bars lookback
    IF high[i] > high[i+1] THEN   //put here anything you like to check
    a = high[i+1] /barindex
    aa = highest[20](a)
    ENDIF
    NEXT
    #76275 quote
    Real ProReal Pro
    Participant
    Average

    ok that attempt was no good.

    I’m trying to create a substitute for a downsloping trendline which can be auto-traded by finding (in psuedocode):

    highest angle in lookback = (high[lookback] – today’s high ) / barindex

    then for each bar after today, subtracting that angle to create a trigger price, until the close >trigger.

    Suggestions very welcome!

    #76276 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Barindex can be 10000 or more, maybe highest angle in lookback = (high[lookback] – today’s high ) / i would be better, but I did not test it.

    Real Pro thanked this post
Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

maximum angle in lookback period.


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Real Pro @real-pro Participant
Summary

This topic contains 5 replies,
has 3 voices, and was last updated by robertogozzirobertogozzi
8 years, 2 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 07/14/2018
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...