//@version=4
study("Round to tick", overlay=true)
f_round_up_to_tick(x, mintick)=>
mult = 1 / mintick
value = ceil(x*mult)/mult
f_round_down_to_tick(x, mintick)=>
mult = 1 / mintick
value = floor(x*mult)/mult
var float stopLoss = 101.68
roundedStopLos = f_round_up_to_tick(stopLoss, syminfo.mintick)
if barstate.islast
label.new(bar_index, high, tostring(roundedStopLos))
Source: Rounding to the nearest tick in Pine Script
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…