Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Expose Public Class List

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

    Expose Public Class List

    Yes I know this is Advanced C# coding and Yes I know that NT is not in the business of teaching C# and yes I know that this is not supported by NT. But I am hoping that someone with advanced C# knowledge will toss me a bone.

    I am trying to Expose the List created in the code to other Indicators and Strategies. The code seems to work fine within the indicator and am in fact using it. After spending a few weeks I still have not figured out how to expose it. I am guessing that I need something in the Properties Region and have tried many ideas but no success.

    HTML Code:
    #region Using declarations
    using System;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Xml.Serialization;
    using NinjaTrader.Cbi;
    using NinjaTrader.Data;
    using NinjaTrader.Gui.Chart;
    using System.Collections.Generic;
    #endregion
    
    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {
        //     Use Indicator Name as Prefix to Class Name
        public class htcSampleExposePublicList_SampleListClass
        {
            public int SampleInt; 
            public double SampleDouble;
            public string SampleString;
            public bool SampleBool;
        
            public htcSampleExposePublicList_SampleListClass(int SampleInt, double SampleDouble, string SampleString, bool SampleBool )
            {
                this.SampleInt = SampleInt;
                this.SampleDouble = SampleDouble;
                this.SampleString = SampleString;
                this.SampleBool = SampleBool;
            }
        }    
        
    
        [Description("Learn how to Expose a Publis Class List")]
        public class htcSampleExposePublicList : Indicator
        {
            #region Variables
            // User defined variables (add any user defined variables below)
            public List<htcSampleExposePublicList_SampleListClass> samplelistclass = new List<htcSampleExposePublicList_SampleListClass>();        
            
            #endregion
    
    
            protected override void Initialize()
            {
                Overlay                = false;
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {
                //  Criteria to Clear List
                if (Falling(SMA(20))) 
                    samplelistclass.Clear();
                
                //  Criteria to Add to List
                if (Rising(SMA(20))) 
                    samplelistclass.Add(new htcSampleExposePublicList_SampleListClass(0, SMA(10)[0], "SMA is Rising", true ));
                    
            }
    
            #region Properties
    
                //  What is the Code to Expose "samplelistclass" to other Indicators and Stratagies?
            
            #endregion
        }
    }
    Thanks.

    #2
    TAJTrades - would the ideas discussed here help you perhaps going forward?

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Still have not figure this out so maybe we can try a different approach.

      On the "Volume Profile" indicator that comes with NT7 how can I expose the the SortedDictionary "volumeInfo" so that I can create some code that will add the VolumeInfoItem(up, down, neutral) to determine the price with the highest traded volume. That would be the widest bar on the histogram.

      I looked in the Strategy Builder and did not see an option for this. I am NOT looking for help manipulating the SortedDictionary only how to expose it within the NT 7 environment.

      Thanks again.

      Comment


        #4
        TAJTrades, unfortunately since this is more general C# this is outside of what we can support here however a hint to get you started fruther : the dictionary and VolumeInfoItem class are either defined as private or internal, you could copy over to a standalone test indicator and then expose them via the public modifier. It should at least show up then to be called from another indicator in Intellisense.
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by kujista, Today, 05:44 AM
        0 responses
        6 views
        0 likes
        Last Post kujista
        by kujista
         
        Started by ZenCortexCLICK, Today, 04:58 AM
        0 responses
        8 views
        0 likes
        Last Post ZenCortexCLICK  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        172 responses
        2,281 views
        0 likes
        Last Post sidlercom80  
        Started by Irukandji, Yesterday, 02:53 AM
        2 responses
        18 views
        0 likes
        Last Post Irukandji  
        Started by adeelshahzad, Today, 03:54 AM
        0 responses
        11 views
        0 likes
        Last Post adeelshahzad  
        Working...
        X