简单问题:特定数量的柱线的 RSI 低于 10 时的条件
Simple question: condition for when RSI below 10 for a certain number of bars
我想写一个条件,说明 RSI 低于 10 至少一定数量的柱,例如 3。我不是 pine 脚本的完全菜鸟,但我不知道该怎么做。
基本上就像 RSI 小于 10 的时间超过或等于 这么多柱。
编辑:发生这种情况时,我还想在图表上绘制文本。这是基于 SafetyHammer 回答的相关脚本。即使我查看 RSI 并且这些条件似乎已经满足,图表上也没有绘制任何内容。
twopRSI=rsi(close, 12)
barsinput=input(defval=10, minval=1, title="RSI Value Threshold for Dip", type=input.integer, confirm=true)
mindip=input(defval=3, minval=1, title="Minimum Bars To Count Dip", type=input.integer, confirm=true)
RSIdip= twopRSI < barsinput
RSIdipbars = 0
RSIdipbars := RSIdip ? nz(RSIdipbars[1]) + 1 : 0
diptrue= RSIdipbars >= mindip
plotshape(series=diptrue, title="Dip Label", style=shape.xcross,
location=location.belowbar, color=color.white, text="RSI Dip", textcolor=color.white, size=size.normal)
给你,这将计算 30 以下的柱数,你可以在指标设置中将 30 更改为任意数字。你很幸运,今天早些时候正在考虑在条件为真时计算柱数。
//@version=4
study(title="Relative Strength Index", shorttitle="RSI", format=format.price, precision=2, resolution="")
length = input(title="Rsi Length", type=input.integer, defval=14, minval=1) // User input for rsi length
upper_bound = input(title="Upper Bound", type=input.integer, defval=70, minval=0, maxval=100) // User input for overbought horizontal line
lower_bound = input(title="Lower Bound", type=input.integer, defval=30, minval=0, maxval=100) // User input for oversold horizontal line
rsi = rsi(close, length)
rsiplot = plot(rsi,title="RSI", color=color.new(color.green,10))
upper_hl = hline(upper_bound) // Plot the hlines and assign to be used for fill
lower_hl = hline(lower_bound)
barsinput = input(title="RSI Value Condition to Count Bars", type=input.integer, defval=30, minval=1) // User input for rsi
condition = rsi < barsinput
bars = 0
bars := condition ? nz(bars[1]) + 1 : 0
fill(upper_hl, lower_hl, color=color.purple) // Fills the area between hlines. Default color is pruple.
plot(bars, title="Bars Crossunder", color=color.new(color.aqua,100))
没看到因为
远离 RSI 趋势绘制,因此缩小您将看到它或将位置从柱下方更改为底部,
或
您使用 10 来识别下跌,您可能没有达到低于 10 的 RSI,所以您看不到它。把它改成30来调试,一旦它回到10就可以了。
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SafetyHammer
//@version=4
study("My Script")
upper_bound = input(title="Upper Bound", type=input.integer, defval=70, minval=0, maxval=100) // User input for overbought horizontal line
lower_bound = input(title="Lower Bound", type=input.integer, defval=30, minval=0, maxval=100) // User input for oversold horizontal line
twopRSI=rsi(close, 12)
barsinput=input(defval=10, minval=1, title="RSI Value Threshold for Dip", type=input.integer, confirm=true)
mindip=input(defval=3, minval=1, title="Minimum Bars To Count Dip", type=input.integer, confirm=true)
RSIdip= twopRSI < barsinput
RSIdipbars = 0
RSIdipbars := RSIdip ? nz(RSIdipbars[1]) + 1 : 0
diptrue= RSIdipbars >= mindip
plotshape(diptrue, title="Dip Label", style=shape.xcross, location=location.bottom, color=color.white, text="RSI Dip", textcolor=color.white, size=size.tiny)
rsiplot = plot(twopRSI,title="RSI", color=color.new(color.green,10))
upper_hl = hline(upper_bound) // Plot the hlines and assign to be used for fill
lower_hl = hline(lower_bound)
fill(upper_hl, lower_hl, color=color.purple) // Fills the area between hlines. Default color is pruple.
我想写一个条件,说明 RSI 低于 10 至少一定数量的柱,例如 3。我不是 pine 脚本的完全菜鸟,但我不知道该怎么做。
基本上就像 RSI 小于 10 的时间超过或等于 这么多柱。
编辑:发生这种情况时,我还想在图表上绘制文本。这是基于 SafetyHammer 回答的相关脚本。即使我查看 RSI 并且这些条件似乎已经满足,图表上也没有绘制任何内容。
twopRSI=rsi(close, 12)
barsinput=input(defval=10, minval=1, title="RSI Value Threshold for Dip", type=input.integer, confirm=true)
mindip=input(defval=3, minval=1, title="Minimum Bars To Count Dip", type=input.integer, confirm=true)
RSIdip= twopRSI < barsinput
RSIdipbars = 0
RSIdipbars := RSIdip ? nz(RSIdipbars[1]) + 1 : 0
diptrue= RSIdipbars >= mindip
plotshape(series=diptrue, title="Dip Label", style=shape.xcross,
location=location.belowbar, color=color.white, text="RSI Dip", textcolor=color.white, size=size.normal)
给你,这将计算 30 以下的柱数,你可以在指标设置中将 30 更改为任意数字。你很幸运,今天早些时候正在考虑在条件为真时计算柱数。
//@version=4
study(title="Relative Strength Index", shorttitle="RSI", format=format.price, precision=2, resolution="")
length = input(title="Rsi Length", type=input.integer, defval=14, minval=1) // User input for rsi length
upper_bound = input(title="Upper Bound", type=input.integer, defval=70, minval=0, maxval=100) // User input for overbought horizontal line
lower_bound = input(title="Lower Bound", type=input.integer, defval=30, minval=0, maxval=100) // User input for oversold horizontal line
rsi = rsi(close, length)
rsiplot = plot(rsi,title="RSI", color=color.new(color.green,10))
upper_hl = hline(upper_bound) // Plot the hlines and assign to be used for fill
lower_hl = hline(lower_bound)
barsinput = input(title="RSI Value Condition to Count Bars", type=input.integer, defval=30, minval=1) // User input for rsi
condition = rsi < barsinput
bars = 0
bars := condition ? nz(bars[1]) + 1 : 0
fill(upper_hl, lower_hl, color=color.purple) // Fills the area between hlines. Default color is pruple.
plot(bars, title="Bars Crossunder", color=color.new(color.aqua,100))
没看到因为
远离 RSI 趋势绘制,因此缩小您将看到它或将位置从柱下方更改为底部,
或
您使用 10 来识别下跌,您可能没有达到低于 10 的 RSI,所以您看不到它。把它改成30来调试,一旦它回到10就可以了。
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © SafetyHammer
//@version=4
study("My Script")
upper_bound = input(title="Upper Bound", type=input.integer, defval=70, minval=0, maxval=100) // User input for overbought horizontal line
lower_bound = input(title="Lower Bound", type=input.integer, defval=30, minval=0, maxval=100) // User input for oversold horizontal line
twopRSI=rsi(close, 12)
barsinput=input(defval=10, minval=1, title="RSI Value Threshold for Dip", type=input.integer, confirm=true)
mindip=input(defval=3, minval=1, title="Minimum Bars To Count Dip", type=input.integer, confirm=true)
RSIdip= twopRSI < barsinput
RSIdipbars = 0
RSIdipbars := RSIdip ? nz(RSIdipbars[1]) + 1 : 0
diptrue= RSIdipbars >= mindip
plotshape(diptrue, title="Dip Label", style=shape.xcross, location=location.bottom, color=color.white, text="RSI Dip", textcolor=color.white, size=size.tiny)
rsiplot = plot(twopRSI,title="RSI", color=color.new(color.green,10))
upper_hl = hline(upper_bound) // Plot the hlines and assign to be used for fill
lower_hl = hline(lower_bound)
fill(upper_hl, lower_hl, color=color.purple) // Fills the area between hlines. Default color is pruple.