Using Volume from different source

Hi, I have an ultimate oscillator indicator I created that currently works. I want to add Volume and Volume MA from a 1 minute chart as filters . So, any chart I put the indicator on will use the volume MA thresholds I choose from a 1-minute chart of the same stock no matter if I’m using a renko, HA, or different time chart.

I’m not exactly sure how to code this, when I try with AI I get code and add it to my script. I’m able to compile the script without errors. However, after compiling the indicator disappears from my indicator list and I’m not sure why. Any insight or direction is appreciated.

Thanks, Mitch

Maybe you didn’t ask it the right questions. It’ll have to be a different indicator if your oscillator is in a different panel. This is a start from me asking it. You need to add the second data series. The order matters if you are adding more than one.

// Indicator: Volume with SMA from 1-Minute Series
// Timeframe-independent (always uses 1-minute volume)
using NinjaTrader.NinjaScript;
using NinjaTrader.NinjaScript.Indicators;
using NinjaTrader.Data;
using NinjaTrader.Gui.Tools;
using NinjaTrader.NinjaScript.DrawingTools;

namespace NinjaTrader.NinjaScript.Indicators
{
    public class VolumeSMA1Min : Indicator
    {
        private SMA volumeSMA;

        [NinjaScriptProperty]
        [Range(1, int.MaxValue), Gui.Label("SMA Period")]
        public int SMAPeriod { get; set; }

        protected override void OnStateChange()
        {
            if (State == State.SetDefaults)
            {
                Description         = "Plots volume and volume SMA from 1-minute bars.";
                Name                = "VolumeSMA1Min";
                Calculate           = Calculate.OnBarClose;
                IsOverlay           = false;
                SMAPeriod           = 20;

                AddPlot(Brushes.Blue, "1Min Volume");
                AddPlot(Brushes.Red, "1Min Volume SMA");
            }
            else if (State == State.Configure)
            {
                // Add 1-minute data series
                AddDataSeries(Data.BarsPeriodType.Minute, 1);
            }
        }

        protected override void OnBarUpdate()
        {
            // Ensure we are processing the 1-minute series
            if (BarsInProgress != 1)
                return;

            // Wait until enough bars are loaded
            if (CurrentBar < SMAPeriod)
                return;

            // Calculate volume and SMA on the 1-minute series
            double currentVolume = Volume[0];

            // Instantiate SMA if not already
            if (volumeSMA == null)
                volumeSMA = SMA(Volume, SMAPeriod);

            Values[0][0] = currentVolume;
            Values[1][0] = volumeSMA[0];
        }
    }
}

Thanks Walee for your response,

I’ve gotten very good at asking the right questions. Some days claude acts drunk or stoned and other days he’s sharp as a tack. It’s almost like working with a human. LOL. All I did was remind him of what he said yesterday about AddDataSeries and he responded with no, that will not work but BarsRequest.GetBars will, and he got it to work. So if he knew that today why did he try the previous method yesterday? he must have been stoned (not that that’s a bad thing), is all I can think of.

My ultimate oscillator now has a 1 minute volume filter amongst other things.

If you access it via dashboard, every query is attached to system prompt made by Antistrophic to shape reasoning/censorship/temperament/etc. The query is being tweaked all the time. I presume this is what made it dumber, more independent, trying to conserve resources.

Nowadays, your prompts need to be more specific than before to get the same results. Try formulating your question using ChatGPT and send it to Sonnet once done.