Decimal places / round up OR round down number

still working on my favorite " EW & Fibs" code -- I am using " PlotTextSetFont " for getting the values on the chart.

Is there anyway to round up / round down the values - number.

Kindly see screen shot below.

thanks

image

hello @JEETU

We can use INT() function . Removes the fractional portion of NUMBER or ARRAY and returns the integer part.

SEE ALSO
The ceil() function; the floor() function; the frac() function.

AFL Function Reference

  • The formula "int( 10.7 )" returns 10; the formula "int(-19.8 )" returns -19.

  • The formula ceil( 6.2 ) returns 7; the formula ceil(-6.2) returns -6.

  • The formula "round( +11.5 )" returns +12. The formula "round( -11.4 )" returns -11.

  • The function floor( 18.9 ) returns 18.

  • The formula floor( -19.9 ) returns -20.

3 Likes

Hi,

I have used "round" function

Good morning @JEETU

With "int" function

text = NumToStr(   SelectedValue( int( Close)) ,1 );
PlotTextSetFont( text, "arial", 40, BarCount, Close[ BarCount - 1 ], colorGreen, colorDefault, -30 ); 

or with "round" function

text = NumToStr(   SelectedValue( round( Close)) ,1 );
PlotTextSetFont( text, "arial", 40, BarCount, Close[ BarCount - 1 ], colorGreen, colorDefault, -30 );