Tradespot

ADW - Colour Trend

Tradespot 已更新   
Colour Trend is an indicator that will give you a visual representation of the trend in a selected market, and alert you when the trend changes. The green colour represents a bullish trend (prices are going up), the red colour represents a bearish trend (prices are going down), and silver represents a neutral trend (prices are relatively stable). The script calculates these trends based on the relative price levels and their moving averages.

Below is a breakdown of the script so you can better understand how these trends are defined.

  • Function f_p(_length, price): This function calculates the price relative to its highest and lowest point over the given `_length` of time. This calculation is normalized by multiplying it by 100, giving us a percentage-like measure.
  • User Inputs: The length of the period (default 12), you can choose to show or hide bar colours (default is true).
  • Variables cycle_avg, cycle_counter, cycle_count, cycle_trend, cycle_col: These variables are used to calculate the trend cycles. The `cycle_avg` is the average trend cycle, `cycle_counter` keeps track of the current trend cycle, `cycle_count` counts the total number of cycles, `cycle_trend` keeps track of the direction of the cycle (1 for up, -1 for down), and `cycle_col` defines the colour of the current cycle.
  • Variables ph, pl, avg, mean: These variables calculate the price level relative to the highest and lowest prices (`ph` and `pl`), the average of these two levels (`avg`), and the cumulative average of the price level (`mean`).
  • Conditionals for cycle trend: The if-statements are checking whether the price level has reached a trend extreme and then updating the trend cycle, colour, count, and average accordingly.
  • Variable col and bar color: The variable `col` is used to define the colour of the bars based on the average price level. If the `show_barcolor` is true, the colour is determined based on the `avg` value.
  • Alert Conditions: These are conditions that will send alerts to the user when the trend changes. Specifically, the alerts occur when the colour changes from non-green to green (bull trend), from non-red to red (bear trend), or from non-silver to silver (no trend).
版本注释:
  • Initialised variables to 'na' for consistency
  • Simplified alert conditions for readability
版本注释:
Updated license

Wizard money evangelist 🪄✨
开源脚本

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

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想在图表上使用此脚本?