【发布时间】:2021-02-07 04:03:03
【问题描述】:
寻找两个问题的答案。
背景:我有标签的代码最大(和最小)枢轴点。
我要做的是“预先确定”一个枢轴点。常规枢轴点用 Source = RSI, Limit = 21 标识。正在考虑指定 Source = RSI, Limit = 5 以“预识别”可能的枢轴点(用灰色标签绘制)。
如果有更好的方法来做到这一点,我全神贯注
问题 1
在我正在处理的情况下,我做了以下操作
- 绘制红色标签(使用系列:结果是 OB_pivot_data - 见代码 - Source = RSI, length = 21)
- 绘制绿色标签(使用系列:结果是 OS_pivot_data - 见代码 - Source = RSI, length = 21)
- 绘制灰色标签(使用系列,源 = RSI,长度 = 5 )
对于灰色标签,我只想要 ~last~ 值(在本例中,它是 67.06)。我need to have the last value in series 形成(在本例中为upper_bound_pivot[0] = 67.06)见下图图片中之前是我现在所拥有的。 AFTER 是目标。
问题 2
接下来,我想将生成的系列与另一个系列结合起来(像 UNION 一样)。话虽如此,有没有办法实现Series A UNION Series B之类的东西?
它在下面的代码中使用:
// HOWTO : OB_pivot_data UNION testme
如何在 Pinescript 下完成这两项任务?
任何帮助、提示或建议将不胜感激。
TIA
功能枢轴:
pivothl(src, len, isHigh, _style, _yloc, _color, _offset, _displayResults ) =>
p = nz(src[len])
isFound = true
for i = 0 to len - 1
if isHigh and src[i] > p
isFound := false
if not isHigh and src[i] < p
isFound := false
for i = len + 1 to 2 * len
if isHigh and src[i] >= p
isFound := false
if not isHigh and src[i] <= p
isFound := false
if _displayResults and isFound
label.new(bar_index[len], p , tostring( truncate(p, 2) ), style=_style, yloc=_yloc, color=_color, textcolor=color.white)
return_data = isFound == false ? na : p
FUNCTION PIVOTHL_FIRST_ONLY
pivothl_first_only(src, len, isHigh, _style, _yloc, _color, _offset, _displayResults ) =>
start_src = src
upper_bound_pivot = pivothl(start_src, len, true, _style, _yloc, _color, _offset, true )
return_data = upper_bound_pivot == false ? na : upper_bound_pivot
return_data
主要
pivot_OB_LB = input(title="Pivot Over Bought Lookback :", type=input.integer, defval=21 )
pivot_OS_LB = input(title="Pivot Over Sold Lookback :", type=input.integer, defval=21 )
pivot_OB_LB_peek = input(title="Peek Pivot Over Bought Lookback :", type=input.integer, defval=5)
lenH = pivot_OB_LB
lenL = pivot_OS_LB
OB_pivot_data = pivothl(rsi, lenH, true , label.style_labeldown, yloc.price, color.red,0, true)
OS_pivot_data = pivothl(rsi, lenL, false, label.style_labelup , yloc.price, color.green,0, true )
dbug_OB_pivot_data = OB_pivot_data >= 0 ? OB_pivot_data : 0
dbug_OS_pivot_data = OS_pivot_data >= 0 ? OS_pivot_data : 100 // just arbitrary number chosen (100)
[ ... snip ... ]
// get last value only place into series
testme = pivothl_first_only(rsi, pivot_OB_LB_peek, true , label.style_labeldown, yloc.price, color.silver,0, false)
pl_testme = testme > 0 ? testme : 0
plot( pl_testme, offset = -pivot_OB_LB_peek, color=color.purple )
【问题讨论】:
-
如果您提供学习的工作场景,我会尽力帮助您。
标签: pine-script