Thinkscript's Getvalue() in Pinescript

I cannot for the life of me figure out how to recreate this one line of Thinkscript in Pinescript. I have tried using valuewhen, highest, highestall, highestbars, and pivothigh, but none of them end up achieving the same results as tested in thinkorswim. (Image is Tesla daily since April) Image of thinkorswim results

GetValue(highest, 5), -4)

1 Answer

In Thinkscript negative offsets refer to future bars. This is something that can't be done in Pine. Most likely you will have to refactor the entire script by adjusting offsets so that everything is referenced from the point of view of the current bar looking back only.

For example, a simple three bar pivot high in Thinkscript might be coded like this :

pivoth = GetValue(high, -1) < GetValue(high, 0) and GetValue(high, 1) < GetValue(high, 0)

But will have to be refactored like this for Pine :

pivoth = high < high[1] and high[1] > high[2]

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest