首页 > 解决方案 > 图中的两个变量 Tradingview

问题描述

在此处输入图像描述

我有两个计算结果

x1 = if ((o1-c1)/c1)*100 > input
    1 
x2 = if ((o2-c2)/c2)*100 > input 
    2 

我想把这两个变量放在一起,比如

plot (x1 & x2)

所以结果将是 12 或 1 或 2 但我不知道如何替换“&”以使其工作?

标签: pine-script

解决方案


您需要将条件交换为:

//@version=4
study("")
// c1 = ((o1-c1)/c1)*100
// c2 = ((o2-c2)/c2)*100
c1 = close > open
c2 = close[2] > open[2] and close[1] > open[1]

x1 = c1 ? input(1) : 0
x2 = c2 ? input(2) : 0
x3 = (x2 != 0 ? x1 * 10 : x1) + x2
plot(x1, "x1", linewidth = 1)
plot(x2, "x2", linewidth = 2)
plot(x3, "x3", linewidth = 3)

推荐阅读