Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

expose values from one indicator to other Indicator

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    expose values from one indicator to other Indicator

    I've been following the code shown below, which uses two indicators: one where some values are generated, and another that accesses those values. The code works fine, but I'm trying to add some extra text variables. However, when I call these text variables in the second indicator, they appear blank. I'm a bit lost since I haven't been able to make the code work. Is it possible to enter text variables, for example, from the indicator's properties and make them visible in a second indicator?

    Click image for larger version

Name:	image.png
Views:	106
Size:	4.0 KB
ID:	1332894

    I try this

    [XmlIgnore()]
    [Display(ResourceType = typeof(Custom.Resource), Name = "Expriry MM-YY", GroupName = "Parameters", Order = 10)]
    public string ThisExpiryDate
    {
    get { Update(); return expiryDate; }
    set { expiryDate = value; }
    }​

    but when i call using

    UpDownTradeVolumeNV().ThisExpiryDate

    dont show anything in the second indicator


    CODE 1

    Code:
    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion
    
    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators.LaunchPad
    {
        public class UpDownTradeVolumeNV : Indicator
        {
            private Series<double> upVolume;
            private Series<double> downVolume;
    
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                                    = @"Estimates the volumes higher and lower than previous trades";
                    Name                                        = "UpDownTradeVolumeNV";
                    Calculate                                    = Calculate.OnBarClose;
                    IsOverlay                                    = true;
                    DisplayInDataBox                            = false;
                    DrawOnPricePanel                            = false;
                    DrawHorizontalGridLines                        = false;
                    DrawVerticalGridLines                        = false;
                    PaintPriceMarkers                            = false;
                    ScaleJustification                            = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                    //See Help Guide for additional information.
                    IsSuspendedWhileInactive                    = true;
                }
                else if (State == State.Configure)
                {
                }
                else if (State == State.DataLoaded)
                {                
                    upVolume = new Series<double>(this);
                    downVolume = new Series<double>(this);
                }
            }
    
            protected override void OnBarUpdate()
            {
                //Add your custom indicator logic here.
                // Estimate the up and down volume and set the values in the
                // DataSeries instance variables...
                double curC = Close[0];
                double curO = Open[0];
                double curR = High[0] - Low[0]; // Range
                double curV = Volume[0];
                double uVolume;
                double dVolume;
                
                if (curC > curO)
                {
                uVolume = (curR / (2 * curR + curO - curC)) * curV;
                }
                else if (curC < curO)
                {
                uVolume = ((curR+curC-curO) / (2 * curR+curC-curO)) * curV;
                }
                else // (curC = curO)
                {
                uVolume = curV / 2;
                }
                String Zona = "UpDownTradeVolumeNV";
                
                Debug1(Zona, "--- High[0] " + High[0]);
                
                dVolume = curV - uVolume;
                upVolume[0] = uVolume;
                downVolume[0] = dVolume;
    
            }
    
            #region Funciones
                
                #region Debug
                    //*********************************************
                    private bool IsDebug1 = true;
                    
                    private void Debug1(String zona, String message)
                    {
                        PrintTo = PrintTo.OutputTab1;
                        if (IsDebug1) Print(zona +" "+message);
                    }    
    
                    private bool IsDebug2 = true;
                    
                    private void Debug2(String zona, String message)
                    {
                        PrintTo = PrintTo.OutputTab2;
                        if (IsDebug2) Print(zona +" "+message);
                    }    
                    //**********************************************    
                #endregion
                    
            #endregion                
            
            #region Properties
                [Browsable(false)]
                [XmlIgnore()]
                public Series<double> UpVolume
                {
                get {return upVolume;}
                }
                [Browsable(false)]
                [XmlIgnore()]
                public Series<double> DownVolume
                {
                get {return downVolume;}
                }
            #endregion
            
        }
        
    }    
    
    #region NinjaScript generated code. Neither change nor remove.
    
    namespace NinjaTrader.NinjaScript.Indicators
    {
        public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
        {
            private LaunchPad.UpDownTradeVolumeNV[] cacheUpDownTradeVolumeNV;
            public LaunchPad.UpDownTradeVolumeNV UpDownTradeVolumeNV()
            {
                return UpDownTradeVolumeNV(Input);
            }
    
            public LaunchPad.UpDownTradeVolumeNV UpDownTradeVolumeNV(ISeries<double> input)
            {
                if (cacheUpDownTradeVolumeNV != null)
                    for (int idx = 0; idx < cacheUpDownTradeVolumeNV.Length; idx++)
                        if (cacheUpDownTradeVolumeNV[idx] != null &&  cacheUpDownTradeVolumeNV[idx].EqualsInput(input))
                            return cacheUpDownTradeVolumeNV[idx];
                return CacheIndicator<LaunchPad.UpDownTradeVolumeNV>(new LaunchPad.UpDownTradeVolumeNV(), input, ref cacheUpDownTradeVolumeNV);
            }
        }
    }
    
    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
        public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
        {
            public Indicators.LaunchPad.UpDownTradeVolumeNV UpDownTradeVolumeNV()
            {
                return indicator.UpDownTradeVolumeNV(Input);
            }
    
            public Indicators.LaunchPad.UpDownTradeVolumeNV UpDownTradeVolumeNV(ISeries<double> input )
            {
                return indicator.UpDownTradeVolumeNV(input);
            }
        }
    }
    
    namespace NinjaTrader.NinjaScript.Strategies
    {
        public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
        {
            public Indicators.LaunchPad.UpDownTradeVolumeNV UpDownTradeVolumeNV()
            {
                return indicator.UpDownTradeVolumeNV(Input);
            }
    
            public Indicators.LaunchPad.UpDownTradeVolumeNV UpDownTradeVolumeNV(ISeries<double> input )
            {
                return indicator.UpDownTradeVolumeNV(input);
            }
        }
    }
    
    #endregion​


    CODE 2

    Code:
    #region Using declarations
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.Gui.SuperDom;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.Data;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Core.FloatingPoint;
    using NinjaTrader.NinjaScript.DrawingTools;
    #endregion
    
    //This namespace holds Indicators in this folder and is required. Do not change it.
    namespace NinjaTrader.NinjaScript.Indicators.LaunchPad
    {
        public class UpDownVolumePlot : Indicator
        {
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                                    = @" Plots the estimated volumes higher and lower than previous trades";
                    Name                                        = "UpDownVolumePlot";
                    Calculate                                    = Calculate.OnBarClose;
                    IsOverlay                                    = false;
                    DisplayInDataBox                            = true;
                    DrawOnPricePanel                            = false;
                    DrawHorizontalGridLines                        = true;
                    DrawVerticalGridLines                        = true;
                    PaintPriceMarkers                            = false;
                    ScaleJustification                            = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                    //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                    //See Help Guide for additional information.
                    IsSuspendedWhileInactive                    = true;
                    AddPlot(new Stroke(Brushes.Green, 2), PlotStyle.Bar, "UpVol");
                    AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.Bar, "DownVol");
                    AddPlot(Brushes.Gray, "ZeroLine");
                }
                else if (State == State.Configure)
                {
                }
            }
    
            protected override void OnBarUpdate()
            {
                //Add your custom indicator logic here.
                UpVol[0] = UpDownTradeVolumeNV().UpVolume[0];            
                DownVol[0] = -UpDownTradeVolumeNV().DownVolume[0];
                
            
            }
    
            #region Funciones
                
                #region Debug
                    //*********************************************
                    private bool IsDebug1 = true;
                    
                    private void Debug1(String zona, String message)
                    {
                        PrintTo = PrintTo.OutputTab1;
                        if (IsDebug1) Print(zona +" "+message);
                    }    
    
                    private bool IsDebug2 = true;
                    
                    private void Debug2(String zona, String message)
                    {
                        PrintTo = PrintTo.OutputTab2;
                        if (IsDebug2) Print(zona +" "+message);
                    }    
                    //**********************************************    
                #endregion
                    
            #endregion            
            
            #region Properties
    
            [Browsable(false)]
            [XmlIgnore]
            public Series<double> UpVol
            {
                get { return Values[0]; }
            }
    
            [Browsable(false)]
            [XmlIgnore]
            public Series<double> DownVol
            {
                get { return Values[1]; }
            }
    
            [Browsable(false)]
            [XmlIgnore]
            public Series<double> ZeroLine
            {
                get { return Values[2]; }
            }
            #endregion
    
        }
    }​










    Attached Files

    #2
    Hello,

    Thank you for your post.

    I am not seeing any code that tries to reference an ExpiryDate variable in either of the posted scripts - neither script seems to have code related to an ExpiryDate variable.

    I recommend taking a look at this sample script which demonstrates exposing indicator values that are not plots.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    558 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    545 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X