pine-script - 图中的两个变量 Tradingview
问题描述
我有两个计算结果
x1 = if ((o1-c1)/c1)*100 > input
1
x2 = if ((o2-c2)/c2)*100 > input
2
我想把这两个变量放在一起,比如
plot (x1 & x2)
所以结果将是 12 或 1 或 2 但我不知道如何替换“&”以使其工作?
解决方案
您需要将条件交换为:
//@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)
推荐阅读
- sql - 如何通过一个或另一个 ID 列(python pandas)连接两个表?
- android - 将图像保存到共享存储。如果图像存在同名的问题
- javascript - 第一个或/和最后一个项目的停止功能
- javascript - 使用 JSX 为数组中的每个元素创建一个新的 div 元素?
- stata - 按两类排序数据总和
- powerbi - 图表设置和循环依赖问题
- java - Spring Boot CsvMapper bean 在返回使用 Map 创建的 ResponseEntity 时会导致错误
- google-ads-api - 无法使用 GAQL 按标签获取广告系列
- python - 如何逐行拆分从 Azure 服务总线接收的批处理字符串消息?
- ios - 返回 UITableViewCell 子类类型的通用函数