如何绘制最高定义柱数的结果 [英] How to plot the result from highest defining the number of bars with barssince

查看:57
本文介绍了如何绘制最高定义柱数的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用 barssince(cross) 绘制当前柱与 ema(50)ema(200) 的最后一个交叉之间的最高柱的值(ema50,ema200)).函数 highest() 需要一个 integer 而 Barssince 给出一个 series integer.所有变体都得到 pine connot compile with error 的错误:

Try to plot the value of the highest bars between current bar and the last cross of ema(50) and ema(200) using barssince(cross(ema50,ema200)). The function highest() wants an integer and the Barssince gives a series integer. All variants getting the error that pine connot compile with error:

第 4 行:不能用参数 (series[integer]) 调用 `highest`;可用的重载:highest(series, integer) => series;最高(整数)=> 系列脚本.

line 4: Cannot call `highest` with arguments (series[integer]); available overloads: highest(series, integer) => series; highest(integer) => series Script.

//@version=3
study("My Script")
o = 0
o := highest(barssince(cross(sma(close,50),sma(close,200))))
plot(o, color = yellow)

ema 十字架只是一个例子.使用 barssince 计算柱数的 highest() 函数是我的目标.

The ema cross is just an example. The highest() function with a calculated number of bars with barssince is my goal.

如何将结果形式 barsince 转换为 highest() 接受的整数?或者有什么不同的解决方案?

How do I convert the result form barssince to an integer accepted by highest()? Or is there a different solution?

推荐答案

自己实现最高功能:

//@version=3
study("My Script", max_bars_back=5000)

highest_pine(src, len) =>
    max = src[0]
    for i = 1 to len
        if src[i] > max
            max := src[i]
    max

o = 0.0
o := highest_pine(close, barssince(cross(sma(close,50),sma(close,200))))
plot(o, color = green)

这篇关于如何绘制最高定义柱数的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆