OPEN-SOURCE SCRIPT

Pseudo-Renko Stabilized (Val)

█ CALCULATE PSEUDO-RENKO VALUE

Calculates and returns the Pseudo-Renko Stabilized value (or close price) based on a given input value, along with the direction of the current Renko brick. This function adapts the traditional Renko brick size dynamically based on the volatility of the input value using a combination of SMA and EMA calculations. The calculated price represents the closing price of the most recent Pseudo-Renko brick, while the direction indicates the trend (1 for uptrend, -1 for downtrend).


Parameters:

* `val`:
* Type: `float`
* Description: The input value upon which the Pseudo-Renko calculations are performed. You can use any price series or custom value as input.
* `sensitivity`:
* Type: `float`
* Default Value: `1.0`
* Description: Controls the sensitivity of the brick size to the volatility of the `val`. Higher values lead to larger bricks, resulting in a smoother Renko chart. Lower values produce smaller bricks, leading to a more reactive chart.
* Possible Values: Any positive float.
* `length`:
* Type: `int`
* Default Value: `7`
* Description: The length used for calculating the EMA and SMA in the dynamic brick size calculation. It influences how quickly the brick size adapts to changing volatility of the `val`.
* Possible Values: Any positive integer.


Return Values:

* `lastRenkoClose`:
* Type: `float`
* Description: The closing price of the last completed Pseudo-Renko brick based on the `val`.
* `renkoDirection`:
* Type: `int`
* Description: The direction of the current Pseudo-Renko brick based on the `val`:
* `1`: Uptrend
* `-1`: Downtrend
* `0`: No change (initially, or no brick change since the previous bar)


Example Usage:





This example demonstrates how to use the `pseudo_renko` function within an indicator. It takes user inputs for `sensitivity` and `length`, then calculates the Pseudo-Renko values using the average of the `close` and `open` prices as the `val`. The resulting `renkoClose` price is plotted on the chart, with a color change based on the `renkoDirection`. It also illustrates how you can use other values, like `high` and `low`, as input to the function.


Note: The Pseudo-Renko algorithm is based on adapting the Renko brick size dynamically based on the input `val`. This provides more flexibility compared to the normal, but is experimental. The `sensitivity` and `length` parameters, along with the choice of the `val`, offer further customization to tune the algorithm's behavior to your preference and trading style.
Moving AveragesPine utilitiesrenkostabilizer

开源脚本

本着真正的TradingView精神,此脚本的作者已将其开源,以便交易者可以理解和验证它。向作者致敬!您可以免费使用它,但在出版物中重复使用此代码受网站规则约束。 您可以收藏它以在图表上使用。

想在图表上使用此脚本?

免责声明