pine-script - 在脚本中向前和向后移动?
问题描述
我是松树脚本的新手,所以如果问题很简单或不可能,请原谅。
这是我的想法:
如果可能的话,我想写一个松树脚本(在交易视图中),这样对于任何绿色蜡烛(每天的时间范围内)计算两个数字:
number_1:之后连续的绿色蜡烛数。
number_2:在此之前连续的绿色蜡烛的数量。
同样对于任何绿色蜡烛,我想在它上面写 number_1,我想在它下面写 number_2。
预先感谢您的帮助和评论。
解决方案
int greenCount = na
if close > open and close[1] < open[1]
greenCount := 1
else if close > open and close[1] > open[1]
greenCount := greenCount[1] + 1
if close < open and close[1] > open[1] and greenCount[1] > 1
for i = 2 to greenCount[1]
label.new(x = bar_index - i, y = high[i], style = label.style_label_down, color = #00000000, textcolor = color.blue, text = tostring(i - 1))
if not na(greenCount) and greenCount > 1
label.new(x = bar_index, y = low, style = label.style_label_up, color = #00000000, textcolor = color.green, text = tostring(greenCount - 1))
推荐阅读
- azure-devops - 如何保留代理的临时文件夹以便手动从 Azure DevOps 发布管道调用命令
- vue.js - 使用 Vue.js 组合 API 的全局反应状态
- javascript - 无法添加新会员号
- javascript - React - 何时使用 useImperativeHandle?
- javascript - 使用 Vite 构建的 React.js 不包含 service-worker.ts
- c# - C#中PointCollection的数值积分
- postgresql - 如何使用解析功能运行连接?
- reactjs - 在 GraphQL 突变响应中返回动态键
- python - 基于两个数据帧中的多列将值从一个映射到另一个df
- javascript - 如何使用 querySelectorAll 中的变量来选择直接子级