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)
回覆