Round function in PineScript is very simple and allows you to round numbers only to the closest integer number. This is a bit irritating because I very often have to round numbers to some decimal places and not integer. So I created 2 functions I use all the time and now sharing them with you.
roundn - rounds the values in its first argument to the specified number of decimal places.
roundtick - rounds the values to current symbol mintick
How can I round the number of contracts bought and sold at each buy/sell point in my strategy. for example the strategy currently will buy 1.4575 contracts but I want it to buy 1.457 contracts or even 1.458 contracts, whereby the last number after the decimal place is rounded but I'm not too concerned about this.
Thank you
U88888
⋅
Thank you...thank you so much
Hachann
⋅
Thank you very much ! Very useful.
NorthStarDayTrading
⋅
How can we round to the nearest .25? For example, trading the ES, NQ and other Futures instruments, the tick size is 1.0, 1.25, 1.50, 1.75, 2.0. Thanks in advance.