如何将标签四舍五入到小数点后两位?
How do I round labels to two decimal places?
我希望标签只显示两位小数。
//@version=4
study("Previous Candle High and Low", shorttitle = "Previous. H/L", overlay=true , precision = 2)
patternLabelPosLow = low[1] - abs(atr(30) * 0.6)
patternLabelPosHigh = high[1] + abs(atr(30) * 0.6)
l1 = label.new(bar_index[1], patternLabelPosHigh, text=tostring(high[1]), style=label.style_label_right, color = color.black, textcolor=color.white)
l2 = label.new(bar_index[1], patternLabelPosLow, text=tostring(low[1]), style=label.style_label_right, color = color.black, textcolor=color.white)
label.delete(l1[1])
label.delete(l2[1])
l1 = label.new(bar_index[1], patternLabelPosHigh, text=tostring(high[1], "#.##"), style=label.style_label_right, color = color.black, textcolor=color.white)
l2 = label.new(bar_index[1], patternLabelPosLow, text=tostring(low[1], "#.##"), style=label.style_label_right, color = color.black, textcolor=color.white)
我希望标签只显示两位小数。
//@version=4
study("Previous Candle High and Low", shorttitle = "Previous. H/L", overlay=true , precision = 2)
patternLabelPosLow = low[1] - abs(atr(30) * 0.6)
patternLabelPosHigh = high[1] + abs(atr(30) * 0.6)
l1 = label.new(bar_index[1], patternLabelPosHigh, text=tostring(high[1]), style=label.style_label_right, color = color.black, textcolor=color.white)
l2 = label.new(bar_index[1], patternLabelPosLow, text=tostring(low[1]), style=label.style_label_right, color = color.black, textcolor=color.white)
label.delete(l1[1])
label.delete(l2[1])
l1 = label.new(bar_index[1], patternLabelPosHigh, text=tostring(high[1], "#.##"), style=label.style_label_right, color = color.black, textcolor=color.white)
l2 = label.new(bar_index[1], patternLabelPosLow, text=tostring(low[1], "#.##"), style=label.style_label_right, color = color.black, textcolor=color.white)