ACCUMULATED DIFFERENCE

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #225205 quote
    twofinger
    Participant
    New

    HI. Need help returning the value “D”.

    I am trying to compare todays close with yesterdays for a specific hour, in this case 21000. Then I want to accumulate the difference over time, “D”, with a start value of 100, “ONCE D=100”. But the code will only return the value “100” for “D” and not adding the movement per day.

    ONCE D=100
    IF TIME=210000 THEN
    C=CLOSE
    A=(C-C[1])/C[1]//percent movement per day
    B=D*A//Value movment per day
    D=D+B//Accumulated value over time
    ENDIF

    RETURN A*100 AS “PROCENT”, B AS “VALUE”, D AS “ACCUMULATE”

    #225208 quote
    robertogozzi
    Moderator
    Master

    Try this one:

    ONCE D=100
    IF TIME=210000 THEN
       C=CLOSE
       A=(C-C[1])/C[1]//percent movement per day
       B=D*A//Value movment per day
       D=D+B//Accumulated value over time
    ELSE
       X=CLOSE
       A=(X-C)/C//percent movement per day
       B=D*A//Value movment per day
       D=D+B//Accumulated value over time
    ENDIF
    RETURN A*100 AS "PROCENT", B AS "VALUE", D AS "ACCUMULATE"
    #225211 quote
    twofinger
    Participant
    New

    Thank you but it does not work. Will only show “A” now. Did you try it your self?

    Problem it self is probably D=D+B where B should be a fixed value, then it works…

    #225212 quote
    twofinger
    Participant
    New

    Also, I do only want the 24 hour difference, and not hour by hour: I do want to compare one specific hour with the same hour the day before and then accumulate that difference

    Bild-2023-12-13-kl.-12.58.jpeg Bild-2023-12-13-kl.-12.58.jpeg
    #225543 quote
    Jean FX
    Moderator
    New

    The problem is that we also need to define C on the first candlestick, an example of a quick correction:

    ONCE D=100
    ONCE C=1
    IF TIME=210000 THEN
    C=CLOSE
    A=(C-C[1])/C[1]//percent movement per day
    B=D*A//Value movment per day
    D=D+B//Accumulated value over time
    ENDIF
    
    RETURN A*100 AS "PROCENT", B AS "VALUE", D AS "ACCUMULATE"
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.

ACCUMULATED DIFFERENCE


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
twofinger @twofinger Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by Jean FX
2 years, 2 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 12/13/2023
Status: Active
Attachments: 1 files
Logo Logo
Loading...