Up days and down days

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #231556 quote
    LuddeLudde
    Participant
    Junior
    I would like to have an indicator with the following conditions.
    
    If the closing price is up one day, it gives the value 1. If it is up two days in a row, it gives the value 2. If it is up three days in a row, it gives the value 3, and so on.
    
    If the closing price is the same as the previous day, it counts as an up day if the previous day was an up day.
    
    I would like to have an indicator that shows an average for the up days for the last 60 days. For example: If we have one where there is 6 up days in a row,and one where there is 4
     up days in a row and two where there is 2 up days in a row.  The indicator should show (6+4+2+2)/4 =3.5.
    
    I would like a similar one for down days.
    
    The result can be shown in a line chart where both the up days and the down days are shown in the same indicator with two different lines.
    
    Thankful for help
    #231563 quote
    Iván GonzálezIván González
    Moderator
    Legend

    Hi,
    Here you have an example:

    if close > close[1] then
    up = up+1
    dw = 0
    elsif close < close[1] then
    up = 0
    dw = dw+1
    else
    up = 0
    dw = 0
    endif
    
    avgUP = average[60](up)
    avgDW = average[60](dw)
    
    return avgUP as "Avg Up days" coloured("green")style(line,3),avgDW as "Avg Dw Days"coloured("red")style(line,3),up as "Up days" coloured("green",75)style(histogram),dw as "Down Days" coloured("red",75)style(histogram)
    Nobody thanked this post
Viewing 2 posts - 1 through 2 (of 2 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

Up days and down days


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
Ludde @ludde Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by Iván GonzálezIván González
2 years, 5 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 04/15/2024
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...