marketreaderz

Math Round

marketreaderz Atualizado   
Hello Reader,
This is Observer from Vietnam.

PURPOSE
I'd like to share my script for Round Math, it's for only education purpose.

I make the formula math_row(x, y) to round the value as we design and shorten the number appearance (value). It's more flexible than str.tostring(close,format.volume) or others.

HOW TO USE
Formula math_row(x,y)
- x is the value which need to be rounded or shorten
- y is the number which you want to round after "." symbol.

***Shorten***
If x < 1.000, no shorten
If x >= 1.000 and x < 1.000.000, shorten to thousand value with "K" letter
If x >= 1.000.000 and x < 1.000.000.000, shorten to million value with "M" letter
If x >= 1.000.000.000, shorten to billion value with "B" letter

***Round***
If y = 0 => no round
If y = 1 => round to format ###.#
If y = 2 => round to format ###.##
If y = 3 => round to format ###.###
If y is other => round to default format of Tradingview

EXAMPLE
math_row(1.002342, 3) = 1.002
math_row(1923.321, 2) = 1.92K
math_row(221452133, 1) = 221.5M

Hope it useful and clear to you.
Notas de Lançamento:
Update on Chart
Notas de Lançamento:
Revise the format of value > 1B from ###.# to #,###.#
Other cases are unnecessary to revise.
Notas de Lançamento:
Revise the name
Notas de Lançamento:
Update formula for negative number
Script de código aberto

Dentro do verdadeiro espírito TradingView, o autor deste script publicou ele como um script de código aberto, para que os traders possam compreender e checar ele. Um viva ao autor! Você pode usá-lo gratuitamente, mas a reutilização deste código em uma publicação é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.

Quer usar esse script no gráfico?