Price levels

Thanks to the developers for adding arrays to TradingView. This gives you more freedom in Pine Script coding.

I have created an algorithm that draws support and resistance levels on a chart. The algorithm can be easily customized as you need.

This algorithm can help both intuitive and system traders. Intuitive traders just look at the drawn lines. For system traders, the "levels" array stores all level values. Thus, you can use these values ​​for algorithmic trading.
Release Notes: Now you can set the number of historical bars to search for a level. This will avoid getting random levels. Also, you can set a limit on the number of lines on the chart. The old levels will be deleted and will not bother you.

It should be noted that this algorithm is difficult to use on small timeframes due to the limited capabilities of the Pine Script. We can reference a maximum of 5000 historical bars in cycles. Also, the script may receive an error due to a long calculation. Therefore, do not ask too much of the algorithm on small timeframes.
Release Notes: Now you can graphically customize your indicator.
Release Notes: Fixed a small bug in the variable title.
Release Notes: made the code look nice!
Release Notes: made the code look nice!
Remove from Favorite Scripts Add to Favorite Scripts


excellent script for array application! thanks for sharing !
+1 Reply
kitoboynaya blackcat1402
@blackcat1402, Thank. It's good that arrays were added in Pine Script!
Thanks for this script @kitoboynaya. Question: what does it mean when no line appear in a (stock) chart ? How to better adjust its sensitivity? Cheers
@MasBart, You are welcome. Read the comments above the variables. I commented everything. And see how it works on a monthly timeframe, where there are few candles and it's easy to figure it out.
Looks slick dude
Home Stock Screener Forex Screener Crypto Screener Economic Calendar How It Works Chart Features Pricing Refer a friend House Rules Help Center Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Blog & News Twitter
Profile Profile Settings Account and Billing Referred friends Coins My Support Tickets Help Center Ideas Published Followers Following Private Messages Chat Sign Out