首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >找到最高和最低蜡烛的时间

找到最高和最低蜡烛的时间
EN

Stack Overflow用户
提问于 2022-07-22 14:36:19
回答 2查看 199关注 0票数 0

我想画一个盒子,从最高的蜡烛到最后的20支蜡烛的最低。每个盒子有四个侧面:上,下,左和右。对于顶部和底部,我使用的是最高()和最低(),但对于左和右,我如何为最高和最低的蜡烛找到时间呢?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2022-07-22 15:06:32

您可以找到高使用最高和低使用最低的功能。然后,您可以使用barssince函数找到它们的索引。然后,您可以使用它们在最后一个栏使用barstate.islast绘制一个框。下面的例子

代码语言:javascript
运行
复制
//@version=5
indicator(title="Highest Lowest Bar", shorttitle="HLB", overlay=true)

hi=ta.highest(high,20)
lo=ta.lowest(low,20)
hiIndex=ta.barssince(high==hi)
loIndex=ta.barssince(low==lo)
var box b=na
if barstate.islast
    box.delete(b)
    b:=box.new(bar_index-hiIndex,hi,bar_index-loIndex,lo,bgcolor=color.new(color.blue,80),border_color=na)
票数 0
EN

Stack Overflow用户

发布于 2022-07-22 14:41:27

当检测到新的最高/最低值时,请将时间保存在变量中,您也可以在box.new变量中选择使用bar_index。给出使用“时间”的示例

代码语言:javascript
运行
复制
var int time_high = 0
var int time_low = 0

current_highest = ta.highest(20)
current_lowest = ta.lowest(20)

// If new High/Low
if (current_highest != current_highest[1])
   time_high := time

if (current_lowest != current_lowest[1])
   time_low := time
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73082046

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档