Use Lower/Higher Low/ High as Trend signal

Viewing 3 posts - 16 through 18 (of 18 total)
  • Author
    Posts
  • #148792 quote
    LucioleLuciole
    Participant
    Senior

    Sure, here we go

    defparam calculateonlastbars=3000
    cp = 10
    
    once lastpoint = 0
    
    if high[cp] >= highest[2*cp+1](high) then
    PEAK = 1
    else
    PEAK = 0
    endif
    
    if low[cp] <= lowest[2*cp+1](low)  then
    TROUGH = 1
    else
    TROUGH = 0
    endif
    
    if PEAK then
    prevtop = topy
    TOPy = high[cp]
    TOPx = barindex[cp]
    endif
    
    if TROUGH then
    prevbot = boty
    BOTy = low[cp]
    BOTx = barindex[cp]
    endif
    
    if PEAK and (lastpoint=-1 or lastpoint=0) then
    DRAWSEGMENT(lastX,lastY,TOPx,TOPy) COLOURED(200,0,0,255)
    DRAWTEXT("■",TOPx,TOPy,Dialog,Bold,10) coloured(200,0,0,255)
    lastpoint = 1
    lastX = TOPx
    lastY = TOPy
    endif
    
    if TROUGH and (lastpoint=1 or lastpoint=0) then
    DRAWSEGMENT(lastX,lastY,BOTx,BOTy) COLOURED(0,200,0,255)
    DRAWTEXT("■",BOTx,BOTy,Dialog,Bold,10) coloured(0,200,0,255)
    lastpoint = -1
    lastX = BOTx
    lastY = BOTy
    endif
    
    
    // 1 bullish trend is starting
    if boty>prevbot and close>topy and lasty<>lasty[1] and not trendup then
    trendup = 1
    endif
    // 1.1 bullish trend is ending
    //if trough and boty<prevbot and lasty<>lasty[1] and trendup then   //Nicolas
    if Close < boty then
    trendup=0
    endif
    
    // 2 bearish trend is starting
    if topy<prevtop and close<boty and lasty<>lasty[1] and not trenddown then
    trenddown = 1
    endif
    // 2.1 bearish trend is ending
    if Close > topy then
    trenddown=0
    endif
    
    
    //trend background color
    if trendup then
    backgroundcolor(0,200,0,30)
    endif
    if trenddown then
    backgroundcolor(250,0,0,30)
    endif
    
    RETURN //TOPy as "TOPy", BOTY as "BOTy", trendup as "trendup"
    
    PLermite thanked this post
    #162226 quote
    clemencejesseclemencejesse
    Participant
    New

    Great stuff here! Thanks for the code. I have been looking for something to identify L, H, HL, HH trends. The code works perfectly for me.

    #174972 quote
    murre87murre87
    Participant
    Senior

    Anyone got backtestpicture

Viewing 3 posts - 16 through 18 (of 18 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

Use Lower/Higher Low/ High as Trend signal


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 17 replies,
has 4 voices, and was last updated by murre87murre87
5 years, 2 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 10/16/2020
Status: Active
Attachments: 8 files
ProRealCode ProRealCode
Loading...