pine-script - 之后传递的一系列数据如何评估?:
问题描述
我是 pinescript 的新手,我试图了解事情是如何工作的,我正在努力完全理解 iff 语句 (?:) 以及当它们在 ?: 之后传递时它如何评估一系列数据。
higher_than = high > close
x = higher_than ? 1 : 0
b = x > 0 ? higher[2]: na
x 被评估为对于在higher_than 中为真的每个值被替换为1,如果一个值为假,它被替换为0。但是b 语句呢?这行得通吗?
对于 x 中优于零的每个值,用相同索引处的更高值替换它?
解决方案
这向您展示了如何调试脚本,以便您可以检查每个条的所有计算值。使用数据窗口进行调试非常有用。通过检查其中的值,您应该能够回答自己的问题。如果你不能,就这么说吧。
//@version=4
study("Debugging", "", true)
higher_than = high > close
x = higher_than ? 1 : 0
b = x > 0 ? high[2]: na
// This is a boolean so we plot a dot when it's true.
plotchar(higher_than, "higher_than", "•", location.top)
// This is a 0/1 value so we can't plot it on the chart because it will ruin the scale, so we plot it in the Data Window.
plotchar(x, "x", "", location.top)
// This value fits in the chart's price scale, so we can plot it directly on the chart. This plots the high from 2 bars ago.
plot(high[2], "high[2]")
// This also fits on the chart, but we use a different color and make the plot wider
// and more transparent so the previous plot in the default blue can show through.
plot(b, "b", color.orange, 5, transp = 60)
推荐阅读
- node.js - 如何使用 heroku 发布 API 项目?
- python - Flask 应用程序似乎无法在 Heroku 找到相关父包
- javascript - React Native - Firebase onSnaphot + FlatList 分页
- react-native - 如何在反应原生 webview 或 exoplayer 中播放 Widevine drm 内容?
- android - 播放控制台 - 使用不同版本的 apk 上传失败,已经有一个版本 1 - 但我有版本 2
- python - 如何在电报机器人中运行时停止工作
- c++ - 重载 C 预处理器宏 - 基于调用语法的区分
- swift - onAppear 中的 SwiftUI 异步数据获取
- algorithm - 如何以编程方式获得公式的派生形式?
- c# - 不能隐式转换类型'System.Collections.Generic.List
' 到 'System.Collections.Generic.IList