Below/Above Trendline

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #206568 quote
    snucke
    Participant
    Veteran

    I would like to know if it is possible to generate signal depending on if price is below or above a trendline

    and how would i convert that into code.

    i have attached a picture of what im looking for.

    ofcourse it depends on how you calculate the Highs and lows etc..

    #206570 quote
    snucke
    Participant
    Veteran

    or is it possible to use the ProReal Oblique trendlines as a signal in below or above in some way?

    #206577 quote
    robertogozzi
    Moderator
    Master

    It’s not possible to know about ojects drawn on the chart.

    The solution is to calculate your own trendline.

    I will code something asap.

    SnorreDK thanked this post
    #208644 quote
    robertogozzi
    Moderator
    Master

    Sorry for the long delay 😔, but I couldn’t write the code you need. I’ll be busy for the next 3 weeks, but I’ll do it soon after.

    #210486 quote
    robertogozzi
    Moderator
    Master

    Sorry for the delay.

    I came up with this one:

    DEFPARAM DrawOnLastBarOnly = true
    ONCE LB = 20     //20 LookBack periods
    myMax   = max(open,close)
    myMin   = min(open,close)
    IF BarIndex > (LB * 2) THEN
       HH2     = highest[LB](myMax[1])
       LL2     = lowest[LB](myMin[1])
       HH1     = highest[LB](myMax[1+LB])
       LL1     = lowest[LB](myMin[1+LB])
       DrawSegment(BarIndex[LB*2],HH1,BarIndex,HH2) coloured("Green") style(line,2)
       DrawSegment(BarIndex[LB*2],LL1,BarIndex,LL2) coloured("Red")   style(line,2)
    ENDIF
    RETURN

    it’s a starting point. Let me know if this is somewhat helpful.

    snucke and Zigo thanked this post
    #213424 quote
    Aragorna
    Participant
    Junior

    Hi Roberto,

    just a question, how do you call this trendline in a strategy? I mean, If  I say close crosses over “what” ?

    thank’s in advance

    #213517 quote
    Nicolas
    Keymaster
    Master

    You need to build affine function of the trendline and check if price is above/below of the current value of the function, example: https://www.prorealcode.com/topic/etendre-drawray-sur-x-barres/#post-137968

    #213537 quote
    Zigo
    Participant
    Master
    
    DEFPARAM DrawOnLastBarOnly = true
    ONCE LB = n     //20 LookBack periods
    myMax   = max(open,close)
    myMin   = min(open,close)
    IF BarIndex > (LB * 2) THEN
    HH2     = highest[LB](myMax[1])
    LL2     = lowest[LB](myMin[1])
    HH1     = highest[LB](myMax[1+LB])
    LL1     = lowest[LB](myMin[1+LB])
    DrawSegment(BarIndex[LB*2],HH1,BarIndex+Lb,HH2) coloured("Green") style(line,2)
    DrawSegment(BarIndex[LB*2],LL1,BarIndex+Lb,LL2) coloured("Red")   style(line,2)
    ENDIF
    RETURN
    #213540 quote
    Zigo
    Participant
    Master

    2 times the indicator once with a Lookback period of 20 and one with the lookback period of 10 candles.
    In the modification also 10 Candles forwards.

    #213541 quote
    Zigo
    Participant
    Master

    Here the picture

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

Below/Above Trendline


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
snucke @snucke Participant
Summary

This topic contains 9 replies,
has 5 voices, and was last updated by Zigo
2 years, 9 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 12/31/2022
Status: Active
Attachments: 3 files
Logo Logo
Loading...