I’m a beginner in pine coding not in “regular coding” and I’m having a hard time understanding what information the highPrev
variable holds from the bellow f_findDivs ()
function.
For reference, this is an extract of the VuManChu Cipher B + Divergences indicator which source can be found here : https://fr.tradingview.com/script/Msm4SjwI-VuManChu-Cipher-B-Divergences/
f_top_fractal(src) => src[4] < src[2] and src[3] < src[2] and src[2] > src[1] and src[2] > src[0]
f_bot_fractal(src) => src[4] > src[2] and src[3] > src[2] and src[2] < src[1] and src[2] < src[0]
f_fractalize(src) => f_top_fractal(src) ? 1 : f_bot_fractal(src) ? -1 : 0
f_findDivs(src, topLimit, botLimit, useLimits) =>
fractalTop = f_fractalize(src) > 0 ? src[2] : na
fractalBot = f_fractalize(src) < 0 ? src[2] : na
highPrev = valuewhen(fractalTop, src[2], 0)[2]
[…]
f_top_fractal
and f_bot_fractal
detect a fractal “shape” of data.
- Is
fractalTop
the same value on each iteration whenvaluewhen()
uses it a the condition on previous values of the src[2] series ? valuewhen()
returning a value, why applying the historical operator[2]
on the result of thevalueWhen()
? Which history is it ?- The documentation does not tell about truthy and falsy values. Is any integer/float considered as
true
when passed to the condition parameter ofvaluewhen()
NB: in the quoted code, I removed from the source the useLimits
logic for the sake of focus
Thanks in advance for any answer or comment, this language is really brainf???????? me