[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Percent - Math 101?



PureBytes Links

Trading Reference Links

Maybe I'm forgetting my grade school math here, but is there an 
easier way to calculate the percentage difference between two numbers?

If I have two numbers, say:

5, 7

To calculate percentage I take the smaller and divide by the larger:

5/7 = .7142857

Then subract 1 = -.2857143
Get rid of the - sign and have .2857143 percent

Problem is this assumes I know which is smaller and which is larger. 
Reversing the numbers doesn't work, i.e., 7/5 doesn't work at all. So 
I have this AFL formula:

daypercent = iif(close > ref(close,-1), ref(close,-1) / close, 
close / ref(close, -1));

Isn't there an easier math technique to figure the percentage between 
2 numbers regardless of which is larger?