Hi Pete (Or anyone else who wants to read),

I'm trying to write a custom standard deviation formula that calculates the standard deviation for only positive/negative days.

I'll include my custom formula below, but it seems to be creating a graph that has many "holes and gaps" in it. I would understand this happening if the custom formula were returning undefined values but from what I gather I don't believe it should be. Here is the code:

days=parameter("Days");

psum=sum(if(close>open,power((close-open),2),0),days);

pdays=hadalert(close>open,days);

PDEV=sqrt(psum/pdays);

Just to quickly explain, the "psum" should just be the summation of all the squared positive daily changes and 0's for any negative days.

The pdays should be returning the number of days the close is greater than the open.

Finally, the standard deviation formula is the sum of the squared deviations, divided by the number of periods included.

I'm almost positive I've got my math right, but I can't seem to understand why I've got gaps and holes.

Thanks!

Joe