Trading View / Pine Editor > Can you group Plots together in a custom indicator?

So I'm trying to group together Plots for a custom indicator I've build from other indicators.

In the screenshot you can see the Plot Backgrounds for the Fill are at the bottom, but I would like them to be below the two MAs I have the fill working on.

Style Menu Plot Background at the bottom

1

The plotshape works and is located correctly just not the Plot Background.

Below is the code I have written for this section. I can provide the entire indicator code if that helps.

// MA default settings: Color, Width and Fill for MA 1 and MA 2 Cross
mA1 = plot(series=mA01, style=plot.style_line, title='MA #1', color=color.new(color.yellow, 0), linewidth=2)
mA2 = plot(series=mA02, style=plot.style_line, title='MA #2', color=color.new(color.blue, 0), linewidth=2)

// Fill colors for the MA1 and MA2 Cross
color fillColor = mA01 > mA02 ? color.new(color.green,80) : color.new(color.red,80)
fill(mA1,mA2, fillColor)

// Call & Put Signals Style Settings
plotshape(ta.crossover(mA01,mA02) , title = "MA 1 & 2 Cross Call Signal", style = shape.triangleup, location = location.belowbar, color = color.green, textcolor = color.white, size = size.small)
plotshape(ta.crossunder(mA01,mA02) , title = "MA 1 & 2 Cross Put Signal", style = shape.triangledown, location = location.abovebar, color = color.red, textcolor = color.white, size = size.small)

//Additional MAs for whatever purpoose you need. 
mA3 = plot(series=mA03, style=plot.style_line, title='MA #3', color=color.new(color.white, 0), linewidth=2)
mA4 = plot(series=mA04, style=plot.style_line, title='MA #4', color=color.new(color.green, 0), linewidth=2)

Upvotes: 0

Views: 642

Answers (1)

elod008
elod008

Reputation: 1362

The answer goes directly to your posed question, asking for the styling only (no code correction).
If you build everything in pine, you should build your own inputs for the settings that you can customize very simply. The fields will appear on the left to your current "Style" tab.
For that, let's say as a simple example:

// @version=5
indicator("MA test")

input1 = input.color(color.yellow, "MA #1", group="MA-s")
input2 = input.color(color.blue, "MA #2", group="MA-s")
input3 = input.color(color.green, "Color 0", group="MA-s")
input4 = input.color(color.red, "Color 1", group="MA-s")
input5 = input.color(color.white, "Color X", group="Something else")

ma1 = ta.sma(close, 7)
plot(ma1, style=plot.style_line, title='MA #1', color=input1, linewidth=2)
...

As you can see you can group everything the way you want via inputs.

Upvotes: 0

Related Questions