How do I color fill this EMA Chart

nocool

When the crossover between EMA25 and EMA50 happens, I would like to fill in the empty space with a red and green that is see-through.

I know I can use fill(), but I am just not sure how.

//@version=4
strategy("My Script", overlay=true)

EMA25 = ema(close, 25)
EMA50 = ema(close, 50)

bull_cross = crossover( EMA25, EMA50)
bear_cross = crossover( EMA50, EMA25)


plot(EMA25, title="EMA(25)", color=color.orange, linewidth=9 )
plot(EMA50, title="EMA(50)", color=color.purple, linewidth=9 )
paaax

Here you go...

//@version=4 
strategy("EMA Shadow", overlay=true)

EMA25 = ema(close, 25) 
EMA50 = ema(close, 50)

bull_cross = crossover( EMA25, EMA50) 
bear_cross = crossover( EMA50, EMA25)

a = plot(EMA25, title="EMA(25)", color=color.orange, linewidth=9 ) 
b = plot(EMA50, title="EMA(50)", color=color.purple, linewidth=9 )

var color col = na
col := EMA25 > EMA50 ? color.green : color.red
fill(a,b,color=col,transp=40)

The trick is to assign your plots for both EMAs to a variable and use those variables in the fill() function.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I use fill color for negative values in spider chart?

How do I fill the current selection with color?

how do i set fill color of a svg circle with the help of thymeleaf

How do I fill each data set as a different color?

How do I fill an <hr> divider in CSS with a color?

How do I set color hues for a grouped line chart?

How do I give a hexadecimal color to different bars in a bar chart?

How do I change Legend color in a Recharts pie chart?

How do I change the color of percentage label to be white in pie chart without interfering the text label color?

How to add area with break on line chart with fill color

How can I draw/fill solid trend colour / vertical column under a candlestick ( instead of background ) to indicate trend on ema shift?

How do you bind a Color to .fill()?

How do you set the fill color of a TextRange?

How can I fill color the tile leaflet?

How can I fill and color based on a variable

How can I change the fill color in boxplot

How can i fill part of image with color?

Line chart fill color is faded

How do I use array data from 'request.security_lower_tf' to generate an ema/a plot in Pinescript?

How do I let a user click a color to become a function that changes the fill of an svg object on click

Matplotlib: How do I auto-fill the area above a line graph with solid color?

How do I use a pseduo class to "mix-blend-mode" an SVG's fill color?

How do I fill only the bottom third of a canvas with color using the y-axis in Javascript?

How do I fill the color of the cell below the active cell if the two values are the same?

How do I combine feature-state and property based fill-color in Mapbox GL JS?

I want to color candle which is not touching 5EMA

How do I change the line color in Altair's Filled Step chart?

How do I color two different dataframes on one chart using ggplot?

How do I change color of a bar in Vega-lite Bar Chart?