marketreaderz

Math Round

marketreaderz Cập nhật   
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.
Phát hành các Ghi chú:
Update on Chart
Phát hành các Ghi chú:
Revise the format of value > 1B from ###.# to #,###.#
Other cases are unnecessary to revise.
Phát hành các Ghi chú:
Revise the name
Phát hành các Ghi chú:
Update formula for negative number
Mã nguồn mở

Với tinh thần TradingView, tác giả của tập lệnh này đã xuất bản nó dưới dạng mã nguồn mở, vì vậy các nhà giao dịch có thể hiểu và xác minh nó. Chúc mừng tác giả! Bạn có thể sử dụng mã này miễn phí, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?