Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
885 views
in Technique[技术] by (71.8m points)

pine script - How to identify the values in the array of the historical bars rather than showing "NaN"?

How to let the historical bars revealing their values in the array rather than showing "NaN"?. However, when I run the replay mode, they're showing a filled array from the first bar of replaying. The image clarify what I'm referring Replay mode vs Solid mode


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Solution!!!

// 1-3) Search for Pivots (High and Low)
PH = pivothigh(close, 5, 4)
PL = pivotlow(close, 5, 4)

// 2-3) Add Pivot Points on array.
var a = array.new_float(6)
if (not na(PH))
    array.unshift(a,PH)
else if (not na(PL))
    array.unshift(a,PL)

// 3-3) Pick-Up the most Last 6 Pivots (High and Low)
var A = array.new_float(6)
A:= array.slice(a, 0, 6)

//=== array ===
y=label.new(bar_index, close, "Pivots
A= " + tostring(A, '#.##'))
// label.delete(y[1])

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...