我如何将变量保存在 IF condation 中并稍后显示?
变量在 IF 条件外显示 0
我想显示 v1 和 v2
//@version=4
study("Test2", shorttitle = "Test2", overlay=true)
v1 = 0.0
v2 = 0.0
r = high - low
large_candle = rising(r,50)
if large_candle
v1 := high
v2 := low
target = "high = " + tostring(v1) + "\n low = " + tostring(v2)
// label.new(bar_index, high, target, yloc = yloc.abovebar, color = color.red, style = label.style_arrowdown)
if (high-open) > 0.7 * (high-low) and open > close
target = "Target 1 = " + tostring(v1) + "\n Target 2 = " + tostring(v2)
label.new(bar_index, high, target, yloc = yloc.abovebar, color = color.black, style = label.style_arrowdown)
barcolor( large_candle ? color.yellow : na)
注意:我真的需要将这些变量保存为另一个代码(我将此代码编码为简单)。任何想法 ?