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”
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"
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…
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
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"