Peter_O

Function Highest/Lowest by PeterO

Peter_O ที่อัปเดต:   
No matter how much I like PineScript, there are still things missing in the language. One of the most annoying issues is that you cannot set dynamic length value for highest/lowest functions. This length must be fixed integer. But it doesn't make sense in a lot of cases, when you'd like to know what was the highest/lowest value of a series SINCE EVENT in the past, but you don't know WHEN this event exactly happened.

Us, coders would like to do this: `highest(series,barssince(...))`

But it is not working.

Numerous coders are using RicardoSantos' f_highest/f_lowest script (www.tradingview.com/...tion-Highest-Lowest/), probably the most often copy/pasted snippet of PineScript code out there. It is doing more-less what `highest(series,barssince(...))` would be doing, but with hardcoded max bars back.

Ricardo is my idol by the way, but that didn't stop me from creating my own version of Highest/Lowest functions. They are fast, simple, effective and very light for Pine engine.

Please treat this as an OPEN SOURCE snippet of code, which can be used in variety of ways.
I have implemented a simple use-case myself, to demonstrate what can be done. The example shows what was the highest/lowest value of RSI since the previous cross of Stochastic. So that you don't enter SHORT on Stochastic crossunder, if RSI didn't reach oversold (<30) since the previous Stochastic crossunder = aka maybe the downtrend has exhausted.

I'm sure you'll find plenty of use cases for it in your studies and strategies as well. If you create your own code using my Highest/Lowest functions, don't hesitate to put a link down here in comments.

P.S. This is not a strategy in any way, so don't ask me "does it backtest well?".
P.S.2 This code doesn't repaint as well ;)
เอกสารเผยแพร่:
Removed unnecessary nz() calls. This is much cleaner. Thanks LucF for tutoring me!
เอกสารเผยแพร่:
One more cleaning fix delivered thanks to LucF's mentorship :)

I auto-execute TradingView Alerts into MT4/MT5 using this: www.tradingconnector.com 1-second delivery. Ping me if you need support with installation.
สคริปต์โอเพนซอร์ซ

ด้วยจิตวิญญาณของ TradingView อย่างแท้จริง ผู้เขียนสคริปต์นี้ได้เผยแพร่เป็นโอเพนซอร์ส เพื่อให้ผู้ค้าสามารถเข้าใจและตรวจสอบได้ ไชโยให้กับผู้เขียน! คุณสามารถใช้ได้ฟรี แต่การใช้รหัสนี้ซ้ำในสิ่งพิมพ์อยู่ภายใต้กฎของบ้าน คุณสามารถตั้งเป็นรายการโปรดเพื่อใช้บนชาร์ตได้

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมที่ เงื่อนไขการใช้บริการ

ต้องการที่จะใช้สคริปต์นี้บนชาร์ตใช่ไหม?