Change versus ROC Question

I am looking to calculate the average percentage gain of up days over the past 200 trading days using the following script:

UpClose = CLOSE() IsUp;
UpGain = If( UpClose, ROC(), 0 );
AvgGain = MA(UpGain, BARS=200);

If I use ROC(1) in my calculation I receive negative values, which does not make sense to me.

If I use CHANGE(1), I get results that appear to make more sense (all positive values), but now questioning my methodology.

Can you please advise what I am missing?

Thank you,

Eric

Hi Eric,

ROC(1) isn’t the correct syntax so it will be using the default 10 bar change in the calculation. You need to use ROC(BARS=1) by changing the parameters in the popup box:

image

The CHANGE() function uses 1 bar by default so even though the syntax was wrong for that one also, it used the correct value.

Thank you Darren. I am now officially emabarrased! :laughing: