Warm tip: This article is reproduced from serverfault.com, please click

Plotting multiple graphs, some overlay, some not

发布于 2020-12-09 21:03:05

I want to create a few strategies that involve some indicators that should be plotted over the candles, others that should go into their own windows because they have different scales.

Let's say for the sake of the example that we want to plot BB and MACD in the same graph. We want the BB over the candles graph, the MACD into its own window. How do I do this? If I use "overlay=true", both are plot in the candles graph. If I try "overlay=false", then the BBs are not plotted over the candles. Plus, AFAIK we can only have one "strategy(overlay=xx)" per script.

Appreciate your help!

Questioner
42piratas
Viewed
0
Bjorn Mistiaen 2020-12-10 05:26:21

This cannot be done in a single script in Pine. One script always pertains to a single window.
You can however have your indicator bounded to the left scale, so that it doesn't distort the main chart.
To do that, you have to enter the scale parameter on the study() function.

Like this:

//@version=4
study("Quality of earnings", overlay=true, scale=scale.left)

cfo = financial(syminfo.tickerid, "CASH_F_OPERATING_ACTIVITIES", "FY")
net = financial(syminfo.tickerid, "NET_INCOME", "FY")

qoe = cfo/net

plot(qoe, style=plot.style_stepline)

Source of this example is Tradingview Pine script plot staircase chart