Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.17 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////
  2. //  Copyright by HPotter v1.0 11/06/2014
  3. // The theory behind the indexes is as follows: On days of increasing volume,
  4. // you can expect prices to increase, and on days of decreasing volume, you can
  5. // expect prices to decrease. This goes with the idea of the market being in-gear
  6. // and out-of-gear. Both PVI and NVI work in similar fashions: Both are a running
  7. // cumulative of values, which means you either keep adding or subtracting price
  8. // rate of change each day to the previous day`s sum. In the case of PVI, if today`s
  9. // volume is less than yesterday`s, don`t add anything; if today`s volume is greater,
  10. // then add today`s price rate of change. For NVI, add today`s price rate of change
  11. // only if today`s volume is less than yesterday`s.
  12. ////////////////////////////////////////////////////////////
  13. study(title="Positive Volume Index", shorttitle="Positive Volume Index")
  14. EMA_Len = input(255, minval=1)
  15. xROC = roc(close, 1)
  16. nRes = iff(volume > volume[1], nz(nRes[1], 0) + xROC, nz(nRes[1], 0))
  17. nResEMA = ema(nRes, EMA_Len)
  18. plot(nRes, color=red, title="PVI")
  19. plot(nResEMA, color=blue, title="EMA")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement