marketreaderz

Math Round

marketreaderz ที่อัปเดต:   
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.
เอกสารเผยแพร่:
Update on Chart
เอกสารเผยแพร่:
Revise the format of value > 1B from ###.# to #,###.#
Other cases are unnecessary to revise.
เอกสารเผยแพร่:
Revise the name
เอกสารเผยแพร่:
Update formula for negative number
สคริปต์โอเพนซอร์ซ

ด้วยจิตวิญญาณของ TradingView อย่างแท้จริง ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้ผู้ค้าสามารถเข้าใจและตรวจสอบได้ ไชโยให้กับผู้เขียน! คุณสามารถใช้ได้ฟรี แต่การใช้รหัสนี้ซ้ำในสิ่งพิมพ์อยู่ภายใต้กฎระเบียบการใช้งาน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ เงื่อนไขการใช้บริการ

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?