Below/Above Trendline

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #206568 quote
    snuckesnucke
    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..

    1.png 1.png
    #206570 quote
    snuckesnucke
    Participant
    Veteran

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

    #206577 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    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
    robertogozzirobertogozzi
    Moderator
    Legend

    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
    robertogozzirobertogozzi
    Moderator
    Legend

    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
    AragornaAragorna
    Participant
    Average

    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
    NicolasNicolas
    Keymaster
    Legend

    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
    ZigoZigo
    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
    34.png 34.png
    #213540 quote
    ZigoZigo
    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
    ZigoZigo
    Participant
    Master

    Here the picture

    34.2.png 34.2.png
Viewing 10 posts - 1 through 10 (of 10 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

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 ZigoZigo
3 years, 5 months ago.

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