QuantNomad

Proper Round Functions [QuantNomad]

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

I hope they will be useful for you.
סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר סקריפט זה פרסם אותו עם קוד פתוח, כך שסוחרים יוכלו להבין ולאמת זאת. הידד למחבר! אתה יכול להשתמש בו בחינם, אך שימוש חוזר בקוד זה בפרסום הנו בכפוף ל כללי הבית . אתה יכול להגדירו כמועדף ולהשתמש בו בגרף.

רוצה להשתמש בסקריפ זה בגרף?
Courses:
PineScript Programming: https://qntly.com/pineprog
TradingView Essen: https://qntly.com/tve

Access to Pro Indic.: https://qntly.com/proind

YouTube: https://qntly.com/youtube
Discord: https://qntly.com/discord
Telegram: https://qntly.com/tel

תגובות

Thank you very much ! Very useful.
+1 השב
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.
השב
QuantNomad NorthStarDayTrading
@NorthStarDayTrading, Try something like: round(close / 0.25) * 0.25
השב
@QuantNomad, "round_to_mintick" is the answer. Wanted to share with you for future reference.
השב
thank you very much, much appreciated!!
השב
Awesome! Very Helpful!
השב
You're the man. Thnx
השב
hi quand i have a question how can i alert if doble doji side by side and next candle green or red ( doji -> doji -
i have this code buy i need

Precision = input(0.15, minval=0.0001, title="Doji's Max Body size")
barcolor(abs(open - close) <= (high - low) * Precision ? yellow : na)

doji=(abs(open - close) <= (high - low) * Precision ? 1:0)
doji2=(abs(open - close) <= (high - low) * Precision ? 1:0)
plotchar (doji)
השב