Rounding to nearest 5 [SOLVED]
-
- Posts: 1
- Joined: 25 Jun 2010
- Location: Seattle, Washington
Rounding to nearest 5 [SOLVED]
I am trying to round the close to the nearest 5. For example if the close was 834.25 the formula should return 835, if the close is 42.12 the return should be 40. I have tried the GenerateStrike function but it does not seem to work or I am not using it properly and the Round function only rounds to the nearest 1. This should be simple but I am having a hard time with this, any help is appreciated.
- TJ
- Posts: 7743
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2222 times
Re: Rounding to nearest 5
Are you trading options?I am trying to round the close to the nearest 5. For example if the close was 834.25 the formula should return 835, if the close is 42.12 the return should be 40. I have tried the GenerateStrike function but it does not seem to work or I am not using it properly and the Round function only rounds to the nearest 1. This should be simple but I am having a hard time with this, any help is appreciated.
What are the rules for rounding up or down?
Re: Rounding to nearest 5
Try this:
It returned the following values for a sample symbol:
Code: Select all
Value1 = Round(Close / 5, 0) * 5;
Print (Close:10:2, Value1:10:2);
465.25 465.00
464.98 465.00
461.01 460.00
454.45 455.00
467.36 465.00
489.57 490.00
498.50 500.00
497.91 500.00
502.33 500.00
507.74 510.00
501.07 500.00
502.36 500.00
502.96 505.00
501.02 500.00
502.97 505.00
488.59 490.00
490.90 490.00
491.70 490.00
487.22 485.00