简单问题:RSI低于10的条件



我想写一个条件,当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))

Not seeing because

被绘制远离RSI趋势,所以缩小,你会看到它或改变位置从下面的条到底部,

你用10来识别一个下降,你可能没有达到RSI低于10,所以你没有看到它。将其更改为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.

最新更新