Hello,
The following indicator does not return any values.
I want to build an indicator called “a” where each value is the one from the previous bar to which I add the price variation for the day multiplied (weighted) by the volume variation of the day.
- Why it does not work?
- How should the problem be fixed?
Thank you in advance
once a=close
v=volume
rv=v/v[1]
p=close
dp=p-p[1]
a=a[1]+dp*rv
return a
Did you test your indicator on instrument that have Volumes?
Yes Nicolas,
I attach a chart on Pepsico. My indicator is in the bottom window
It should work with this modified code, like you did for the ‘a’ variable, giving only once the volume value to the ‘v’ one, fixed it. Because v[1] is not defined the first time the code is read, the calculation can’t complete itself and that’s why you didn’t get anything.
once a=close
once v=volume
if barindex>2 then
v=volume
rv=v/v[1]
p=close
dp=p-p[1]
a=a[1]+dp*rv
endif
return a