Tradespot

ADW - Colour Trend

Tradespot Atualizado   
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).
Notas de Lançamento:
  • Initialised variables to 'na' for consistency
  • Simplified alert conditions for readability
Notas de Lançamento:
Updated license

Wizard money evangelist 🪄✨
Script de código aberto

Dentro do verdadeiro espírito TradingView, o autor deste script publicou ele como um script de código aberto, para que os traders possam compreender e checar ele. Um viva ao autor! Você pode usá-lo gratuitamente, mas a reutilização deste código em uma publicação é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.

Quer usar esse script no gráfico?