6426 просмотров
Now you can plot a "Renko" chart on any timeframe for free! As with my previous algorithm, you can plot the "Linear Break" chart on any timeframe for free!

I again decided to help TradingView programmers and wrote code that converts a standard candles / bars to a "Renko" chart. The built-in renko() and security() functions for constructing a "Renko" chart are working wrong. Do not try to write strategies based on the built-in renko() function! The developers write in the manual: "Please note that you cannot plot Renko bricks from Pine script exactly as they look. You can only get a series of numbers similar to OHLC values for Renko bars and use them in your algorithms". However, it is possible to build a "Renko" chart exactly like the "Renko" chart built into TradingView. Personally, I had enough Pine Script functionality.

For a complete understanding of how such a chart is built, you can read to Steve Nison's book "BEYOND JAPANESE CANDLES" and see the instructions for creating a "Renko" chart:
Rule 1: one white brick (or series) is built when the price rises above the base price by a fixed threshold value or more.
Rule 2: one black brick (or series) is built when the price falls below the base price by a fixed threshold or more.
Rule 3: if the rise or fall of the price is less than the minimum fixed value, then new bricks are not drawn.
Rule 4: if today's closing price is higher than the maximum of the last brick (white or black) by a threshold or more, move to the column to the right and build one or more white bricks of equal height. A new brick begins with the maximum of the previous brick.
Rule 5: if today's closing price is below the minimum of the last brick (white or black) by a threshold or more, move to the column to the right and build one or more black bricks of equal height. A new brick begins with the minimum of the previous brick.
Rule 6: if the price is below the maximum or above the minimum, then new bricks are not drawn on the chart.

So my algorithm can to plot Traditional Renko with a fixed box size. I want to note that such a "Renko" chart is slightly different from the "Renko" chart built into TradingView, because as a base price I use (by default) close of first candle. How the developers of TradingView calculate the base price I don’t know. Personally, I do as written in the book of Steve Neeson.

The algorithm is very complicated and I do not want to explain it in detail. I will explain very briefly. The first part of the get_renko () function — // creating lists — creates two lists that record how many green bricks should be and how many red bricks. The second part of the get_renko () function — // creating open and close series — creates open and close series to plot bricks. So, this is a white box - study it!

As you understand, one green candle can create a condition under which it will be necessary to plot, for example, 10 green bricks. So the smaller the box size you make, the smaller the portion of the chart you will see.

I stuffed all the logic into a wrapper in the form of the get_renko() function, which returns a tuple of OHLC values. And these series with the help of the plotcandle() annotation can be converted to the "Renko" chart. I also want to note that with a large number of candles on the chart, outrages about the buffer size uncertainty are heard from the TradingView blackbox. Because of it, in the annotation study() set the value of the max_bars_back parameter.

In general, use this script (for example, to write strategies)!
Информация о релизе: Now you can definitely build an intraday Renko chart without a paid subscription!

The previous version of get_renko() function did not work with the number of candles more than 5000. I modified the script and solved this problem.
Previously, the script needed to iterate over the entire data array in a loop. It could be more than 5000 candles. Now the variables up_stop_index and down_stop_index narrow the array to search. However, you can still have problems if you set a very small box size and there will be a lot of candles on the chart.
Информация о релизе: At the request of the users of this script, I have updated the minimum box size.
Now the Renko algorithm can be used in Forex and cryptocurrency with a lot of numbers after point.
Скрипт с открытым кодом

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Хотите использовать этот скрипт на графике?


It did not work on my chart. the reason my account is premium, the chart exceeds 10,000 bars, the indicator didn't work.b please fix it.
+6 Ответить
kitoboynaya innocentTruffl37906
@innocentTruffl37906, Sorry, I think I can’t help. These are the internal problems of TradingView. But you can use my get_linebreak() function to build a Line Break chart. Why is it worse?
kitoboynaya innocentTruffl37906
@innocentTruffl37906, Now I fixed it! :)
+1 Ответить
amazing, thank you!
+1 Ответить
@aes0n, you're welcome! :)
Thanks for sharing the most effective script.
+1 Ответить
It is very good work.
+1 Ответить
Thanks sir. I am hoever getting this error , "Pine cannot determine the referencing length of a series. Try using max_bars_back in the study or strategy function"
+1 Ответить
kitoboynaya RajeevNaik
@RajeevNaik, try set max_bars_back = 10000. It seems that on charts with the number of candles over 5000 this algorithm will not work. Only if a paid subscription allows you to increase the max_bars_back parameter. However, my "Line break" algorithm works on small timeframes. But on "Renko" the black box TradingView swears. It is very strange.
kitoboynaya RajeevNaik
@RajeevNaik, Now I fixed it! :)
+3 Ответить
Домой Скринер акций Скринер форекс Скринер криптовалют Экономический календарь О нас Особенности Цены Приведи друга Правила поведения Справочный центр Решения для сайтов и брокеров Виджеты Графики TradingView для сайтов Легкая версия графиков Блог и новости Твиттер
Профиль Настройка профиля Счёт и оплата Ваши друзья Монеты Мои запросы в поддержку Справочный центр Личные сообщения Чат Выйти