I’ve written a new indicator, and I’d like to add a second plot to it that would be displayed in its own panel at the bottom of the chart, similar to how the built in RSI indicator displays.
I read an old forum post about it, but couldn’t quite make sense of it. In particular, I don’t see how to specify what panel the plot appears in, or how to set the range or thresholds. If it makes a difference, what I’m plotting will return values of 1, 0, or -1. These are buy/do nothing/sell signals, and I want to turn them into a plot so they’re accessible from Strategy Builder.
After I get it set up, it looks like within OnBarUpdate() I just assign values for each plot in the order of their creation with Values[0][0], Values[1][0] etc. But how should I create it?
A single indicator instance can only plot to a single panel. That panel can either be the chart panel or a separate panel. You can control this in your indicator code by using IsOverlay.
You can’t send different plots from the same indicator instance to different panels. That is not supported as far as I know.
In your case, if all you’re trying to plot is the one signal for buy/sell/nothing, then you can define a single plot and just assign it values of 1, 0, -1 as you suggested. You would only use Values[0][0] for assignments. Values[0] refers to the first plot (index 0), Values[1] refers to the second plot (index 1), so and so forth. Since you only have one plot, you will only use Values[0].
In OnBarUpdate:
if (my calculation is bullish)
{
Values[0][0] = 1;
}
else if (my calculation is bearish )
{
Values[0][0] = -1;
}
else
{
Values[0][0] = 0;
}
I think you can do something like this using an add on. I have the main indicator and an additional indicator in the addons. This allows me to sync some values in the main indicator to a different indicator. If you look at the screenshot you can see the main chart and a bottom histogram. You’ll have to add both when selecting indicators. trust-me-bro/AddOns/TrustMeBro/Indicators/TrendScoreIndicator.cs at main · WaleeTheRobot/trust-me-bro · GitHub
Thanks for your reply. I ended up making this a hidden plot with a transparent brush, but with the signals still accessible to other scripts/strategy builder.