A Trend indicator

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #225746 quote
    BryggareBryggare
    Participant
    Average
    Hi I wonder if you could help me create  an indicator that I use for determine if a stock goes sideways.
    I would like to have an indicator that shows how many times the closing price has been touched in the last 30 bars before the current bar.
     For example, if the closing price has touched five bars out of the last 30 bars, the indicator should show 5. The result could be shown in a histogram. 
    
    Thankful if you could help me
    #225748 quote
    JSJS
    Participant
    Master
    Hi @Bryggare Hereby the indicator…  
    Touched=0
    For i=1 to 30
    If Close[i] Crosses Over Close or Close[i] Crosses Under Close then
    Touched=Touched+1
    EndIf
    Next
    Return Touched as "Touched" Coloured("Green")Style(Histogram)
    
    Scherm­afbeelding-2023-12-28-om-09.42.57.png Scherm­afbeelding-2023-12-28-om-09.42.57.png
    #225763 quote
    BryggareBryggare
    Participant
    Average
    Thank you , it works fine
    #225765 quote
    BryggareBryggare
    Participant
    Average
    Hi again.  It seems like the indicator compares to days range with previous close for the last 30 days.  Can you change so that the close of the current bar compares with the hole range from high to low of the previous bars.  For example the to days close compares if it has touched any of the last 30 days bars (from high to low).
    #225772 quote
    JSJS
    Participant
    Master
    Hi,

    This indicator compares whether the current Close falls between the High and the Low (Range) of the previous 30 candles…  

    Touched=0
    For i=1 to 30
    If Close<High[i] and Close>Low[i] then
    Touched=Touched+1
    EndIf
    Next
    Return Touched as "Touched" Coloured("Green")Style(Histogram)

    Bryggare thanked this post
    Scherm­afbeelding-2023-12-28-om-17.09.22.png Scherm­afbeelding-2023-12-28-om-17.09.22.png
    #225778 quote
    BryggareBryggare
    Participant
    Average
    Hi again, now it seems to work. When it is trending it is not touched so many times and when it is not trending it is touched many times. Thank you for helping me
    JS thanked this post
    #225800 quote
    LucasBestLucasBest
    Participant
    Senior
    An other upgrade/version… Try with total price instead of close
    src = customclose
    
    Touched=0
    For i=1 to 30
    If src<High[i] and src>Low[i] then
    Touched=Touched+1
    EndIf
    Next
    
    Filtre = Average[5](Touched)
    
    If Filtre < 5 then
    ColR = 0
    ColG = 128
    ColB = 0
    Else
    ColR = 128
    ColG = 128
    ColB = 128
    Endif
    
    Return 1 as "Ranging Index" Coloured(ColR,ColG,ColB)Style(Histogram)
    Bryggare thanked this post
    #225807 quote
    LucasBestLucasBest
    Participant
    Senior
    Little upgrade… The idea is not bad, but still not accurate as my main range detector.
    src = customclose
    
    Touched=0
    For i=0 to 28
    If src<High[i] and src>Low[i] then
    Touched=Touched+1
    EndIf
    Next
    
    Filtre = ExponentialAverage[2](Touched)
    
    If Filtre < 5 then
    ColR = 0
    ColG = 128
    ColB = 0
    Else
    ColR = 128
    ColG = 128
    ColB = 128
    Endif
    
    Return 1 as "Ranging Index" Coloured(ColR,ColG,ColB)Style(Histogram)
    
    pror thanked this post
    Capture-decran-2023-12-29-123231.png Capture-decran-2023-12-29-123231.png
    #225814 quote
    BryggareBryggare
    Participant
    Average
    Thank you for the upgraded version. I will look on them and see which suits me best
Viewing 9 posts - 1 through 9 (of 9 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

A Trend indicator


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Bryggare @bryggare Participant
Summary

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

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