Rounding up to the nearest tick

Questions about MultiCharts and user contributed studies.
masber2000
Posts: 29
Joined: 15 Aug 2012
Has thanked: 2 times

Rounding up to the nearest tick

Postby masber2000 » 06 Oct 2021

Hello-

I'm trying to figure our a way to roundup to the nearest tick (MinMove / PriceScale):

For example, if using the following example in ES:

round(average ((x - y),100)*z,2) = 1025.12

I would like this figure to round up to the next .25 increment, in this instance, 1025.25. I'm not sure how to do this in Multicharts.

Thank you for your help in advance.

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: Rounding up to the nearest tick

Postby ABC » 07 Oct 2021

masber2000,

there are multiple ways to accomplish what you have in mind. It depends a bit on what you want to do in case your value is already ending at the nearest tick i.e. would 1025.25 still be rounded up to 1025.50.

One way to always round up would be:
1. Dividing the value by one tick and adding one to the integer portion of the result
2. Multiplying the result of 1. by one tick again.

If you do not want to round values like 1025.50 (and you are only dealing with positive values) you could use "Ceiling" instead of "IntPortion" in 1. and not add one.

Regards,

ABC

masber2000
Posts: 29
Joined: 15 Aug 2012
Has thanked: 2 times

Re: Rounding up to the nearest tick

Postby masber2000 » 10 Oct 2021

Mathematics is Magical!

Thank you kindly for the solution ABC.


Return to “MultiCharts”