Highlight Crossover - Background Color Example


Hidden Redirect Link
Loading...

This educational indicator demonstrates how to use the @plot.background() decorator in Indie to visually highlight important market events.
The indicator tracks crossovers between 15 and 30-period SMAs. When the fast SMA crosses above the slow SMA, it marks the chart background with a teal color that gradually fades over time. The fading effect is achieved through a simple formula:

alpha = 0.5 / (self.bar_index - cross_over_index.get() + 1) ** 0.6

Key features demonstrated: 

  • Using @plot.background() to color the chart background
  • Storing state with Var[int] to remember when crossovers occurred
  • Creating transparency gradients with dynamic alpha calculation

This example shows how background coloring can make it easier to spot recent crossover areas on the chart, helping traders quickly identify potential trend changes.

educationalindicator
plot-background
© Licensed under MIT

Comments

loading