Adding the Sum operator to a script

I successfully created the following script for the Intraday Intensity indicator:

(2*CLOSE() - HIGH() - LOW()) / (HIGH() - LOW()) * VOLUME()

However, I would like to expand this formula in the following manner with the Sum operator:

SUM((2*CLOSE() - HIGH() - LOW()) / (HIGH() - LOW()) * VOLUME(),21) / SUM(VOLUME(), 21)

How would I re-write this formula to be accepted in the Script Manager?

Thank you,

Paul M


Probably a better way to ask my question is how to create a script that accomplishes the following:

21-day sum of [2*CLOSE() – HIGH() – LOW()) / (HIGH() – LOW()) * VOLUME()] / 21-day sum of volume

Thanks for any help.

Paul M

Hi Paul,

We can use the ACC() function to sum up the last 21 days in your script:

V1 = (2*CLOSE() - HIGH() - LOW()) / (HIGH() - LOW()) * VOLUME();
V2 = ACC(V1, RANGE=Look Back Period, BARS=21) ;
V3 = ACC(VOL(), RANGE=Look Back Period, BARS=21) ;
V2 / V3

This is how the result looks on a chart using a Show View tools:


Thank you very much - really appreciate it. Paul