Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Helper class

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

    Helper class

    Hi guys,


    I have an idea but not sure how to implement that.

    I have created 10 indicators and 5 strategies. I have the same paramaters for a few of them. For example I have an option to calculate volume based on past days or manually put a number. I use these properties on 5 indicators and 5 strategies. I would like to enter these properties only once.

    Is there a way that I could set an indicator that would get these parameters only once and that the other indicators and strategies could refer to. I thought of a statis class but don't know how to set up things ?



    Thanks

    Bernard

    #2
    Bernard,

    Unfortunately this is beyond the level of support we can offer.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Put the values into a text file and read from it.

      Comment


        #4
        Thanks Baruch

        This is something I thought I would do as my last option





        Bernard

        Comment


          #5
          This is the best option. In other solutions you will have to enter the parameters each day.

          Comment


            #6
            Hi Bernard,

            if you could accept or even desire that each of the concerning indicators holds all of these shared parameters as own properties, then you could store them with the workspace (xml file). In this case you don't need to maintain an own text file.

            Then you only need to keep these parameters in sync and I think desinging a static helper class is a proper way to go. In this case I would implement the following:
            • Store the concerning parameters as local variables in the helper class.
            • Implement a registration-method. Every indicator/strategy needs to register itself one time. You store the this-pointers of the indicators/strategies in an array or list locally in the helper class. This way you have access to the public interface of all registered instances.
            • Implement an update-method. Whenever you modify one of the shared parameters, the concerning indicator/strategy calls the update-method of the static helper class. This update-method stores the changed value and updates this parameter for all registered instances via the public interface.

            All methods described above are static by nature, because the helper class is static.

            Regards
            Ralph

            Comment


              #7
              possible solution

              Thanks Ralph

              In the meantime I have created a new indicator with static class. I think I am close to getting what I want. Here is my code. Tell me what you think !

              I will sumit in two post :

              publicclass v1SetUp : Indicator
              {
              #region Variables
              // Wizard generated variables
              privatebool rV_Auto= true;
              privateint rV_Manual = 0;
              privateint volTicks = 6;
              // User defined variables (add any user defined variables below)
              #endregion
              ///<summary>
              /// This method is used to configure the indicator and is called once before any bar data is loaded.
              ///</summary>
              protectedoverridevoid Initialize()
              {

              CalculateOnBarClose =
              true;
              Overlay =
              false;
              PriceTypeSupported =
              false;

              }
              ///<summary>
              /// Called on each bar update event (incoming tick)
              ///</summary>
              protectedoverridevoid OnBarUpdate()
              {

              Settings.SetStuff(rV_Auto, rV_Manual, volTicks);


              Print(Settings.Auto);
              Print(Settings.Manual);
              Print(Settings.VolTicks);

              }

              Comment


                #8
                Post 2

                staticpublicclass Settings{

                staticint _manual;
                staticbool _auto;
                staticint _volticks;

                publicstaticint Manual
                {
                get {return _manual ; }
                set {_manual = value; }
                }

                publicstaticbool Auto
                {
                get {return _auto ; }
                set {_auto = value; }
                }

                publicstaticint VolTicks
                {
                get {return _volticks ; }
                set {_volticks = value; }
                }


                publicstaticvoid SetStuff(bool rvauto, int rvmanual, int volticks)
                {
                _manual = rvmanual;
                _auto = rvauto;
                _volticks = volticks;

                }

                Comment


                  #9
                  post 3

                  static Settings()
                  {
                  _manual =
                  0;
                  _auto =
                  true;
                  _volticks =
                  6;
                  }

                  }

                  Comment


                    #10
                    Hi Bernard,

                    you are a fast programer.

                    I guess, with post 3 you are initiating the helper class variables. So, I assume it is the constructor of the helper class? Maybe you could set these immediate variables directly, like in a "normal" class (i.e. static bool _auto = true; ).

                    With this concept, every indicator is responsible by itself to check for updates of the helper class variables. If that is a feasible way to go, then you don't need to code the registry concept and can keep the concept as simple as presented.

                    Regards
                    Ralph

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    651 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    370 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    109 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    574 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    577 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X