简体   繁体   中英

Pine script barssince confused

I am new to Pine script and I will appreciate it very much any kind of help. I have been using Python for my strategies but I am very interested in Pine script. Based on the code below I would like to know if on the line below "NH = valuewhen(high>k1[1],high,0)" is k1[1] a series (list) or just one value. What about barssince(high>k1[1]) below? Basically my question is: what is the difference of the value of k1[1] between valuewhen(high>k1[1],high,0) and barssince(high>k1[1])

boxp=input(5, "BOX LENGTH")

LL = lowest(low,boxp)
k1=highest(high,boxp)
k2=highest(high,boxp-1)
k3=highest(high,boxp-2)

NH =  valuewhen(high>k1[1],high,0)
box1 =k3<k2
TopBox = valuewhen(barssince(high>k1[1])==boxp-2 and box1, NH, 0)

highest() returs series float so, k1 is of series in all cases.

[] in pinescript is called History reference operator and is used to refer to the historical values of any variable of the series type.

So, k[1] refers to k 's previous value.

valuewhen(high>k1[1],high,0) will return the high price when high > k[1] was true the last time.

barssince(high>k1[1]) will tell you how many bars ago this was.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM