[英]RSI Failure Swing Pine Script Problem for Tradingview
I would like to code the RSI Failure Swings .我想对RSI 失败波动进行编码。 Things I need for the calculation:
我需要计算的东西:
I already managed to give a heads up when the divergence happens, so point 1 and 2 are fine.当分歧发生时,我已经设法提醒了,所以第 1 点和第 2 点很好。 But how do a get the lowest/highest RSI reading between those bars?
但是如何获得这些柱之间的最低/最高 RSI 读数?
I tried something like this for a Top Failure Swing (AKA Bearish Failure Swing):我尝试了这样的顶部失败摆动(又名看跌失败摆动):
lowestrsi = valuewhen(bearishdivergence, lowest(rsi, barssince(overbought)), 0)
My thinking was: find the bar with bearish divergence and return the lowest RSI reading between that bar and the bar prior to that with a overbought condition.我的想法是:找到具有看跌背离的柱线,并返回该柱线与处于超买状态之前的柱线之间的最低 RSI 读数。
But that doesn't work because the second argument of lowest()
can't be a series!但这不起作用,因为
lowest()
的第二个参数不能是一个系列! If you replace that argument with a number, let's say 10, it works perfectly and I get notified of a failure swing.如果您用一个数字替换该参数,例如 10,它可以完美运行,并且我会收到摆动失败的通知。 But the problem is, is that there's no default value for something like this.
但问题是,像这样的东西没有默认值。 Meaning you can't hardcode something like '10' or some other number.
这意味着您不能对诸如“10”或其他数字之类的内容进行硬编码。
Question: How do I get the lowest RSI between the bars mentioned at point 1 and 2?问题:如何获得第 1 点和第 2 点提到的柱线之间的最低 RSI? Or how do I turn a series into an integer?
或者我如何将一个系列变成一个整数? Is that even possible?
这甚至可能吗? Or is it possible to get a single integer from a series?
或者是否有可能从一个系列中得到一个整数?
You might wanna try RicardoSantos' Highest/Lowest function.您可能想尝试 RicardoSantos 的最高/最低功能。 It helped me as a workaround to the similar problem in the past: https://www.tradingview.com/script/32ohT5SQ-Function-Highest-Lowest/
它帮助我解决了过去类似的问题: https : //www.tradingview.com/script/32ohT5SQ-Function-Highest-Lowest/
//@version=2
study(title='Function Highest/Lowest', overlay=true)
src = input(close)
length = input(10)
f_highest(_src, _length)=>
_adjusted_length = _length < 1 ? 1 : _length
_value = _src
for _i = 0 to (_adjusted_length-1)
_value := _src[_i] >= _value ? _src[_i] : _value
_return = _value
f_lowest(_src, _length)=>
_adjusted_length = _length < 1 ? 1 : _length
_value = _src
for _i = 0 to (_adjusted_length-1)
_value := _src[_i] <= _value ? _src[_i] : _value
_return = _value
h = f_highest(src, length)
l = f_lowest(src, length)
plot(h)
plot(l)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.