Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using output variables within a strategy?

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

    Using output variables within a strategy?

    Greetings,

    I'm trying to code my first strategy. My question is how do you use the wizard to extract "calculated output" variables from within an indicator? For example I see where you can have the inputs of a particular indicator manipulated to do things...however what about variables whose values are calculated within the indicator? They don't seem to show up as optional values to use within the wizard...

    Thanks in advance.

    #2
    Hi Burga1,

    When you choose the indicator from the list there will be an option known as "Plot". From there you can choose any variable that is exposed in the indicator. For example, if you look at the Stochastics indicator you will see a plot for the D and the K values. You can choose whichever one you want to use.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Hmm, OK I see that. So if I have a custom indicator I made and I want to be able to access variables calculated within that indicator--I need to make them "Plots"...and would that be accomplished using this code for example:

      Add(
      new Plot(Color.FromKnownColor(KnownColor.PaleTurquoise ), PlotStyle.Line, "Name equal to my variable"));

      If that is not correct then can you please let me know...? Thanks in advance.

      Comment


        #4
        That is one way to do it. Another is to just store data in a DataSeries object and provide a public property for this DataSeries object.
        RayNinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Ray View Post
          That is one way to do it. Another is to just store data in a DataSeries object and provide a public property for this DataSeries object.
          Ray, can you put in the pipeline some example regarding public property for DataSeries in the Reference Sample Section.


          Regards,

          Comment


            #6
            Already ahead of you

            Will have something in the near future... Thanks for the suggestion!
            RayNinjaTrader Customer Service

            Comment


              #7
              OK, thanks...so something like this should be acceptable then...

              Add(new Plot(Color.FromKnownColor(KnownColor.PaleTurquoise ), PlotStyle.Line, "SIGNAL"));
              ...
              VALUE1 =
              100 * (Inside12 / Inside22);

              Signal.Set(VALUE1);
              SIGNAL = EMA(Signal, Sig)[
              0];

              thanks in advance.

              Comment


                #8
                Sorry, another question. What happens if it is named incorrectly? I used the wizard initially to setup the code template and inadvertantly used names I didn't want for the "Add(new plot...etc)" line. It seems I cannot simply change the names, they still appear in the strategy wizard under the old names in the "Plot" field...thanks again.

                Comment


                  #9
                  Check under the "Properties" region and remove any unwanted properties.
                  RayNinjaTrader Customer Service

                  Comment


                    #10
                    Thanks. That worked to remove the unwanted properties. However now I have no properties to be able to choose from in the strategy builder. I guess that code I wrote below in the 5:17pm post is not acceptable then?

                    Comment


                      #11
                      We will post a reference sample in the near future that will illustrate the correct approach for exposing a property.

                      In a nutshell, declare a DataSeries variable internal to your strategy, set values to it, expose this DataSeries as a property.

                      See the reference sample section for info on DataSeries, then look at any indicator's "Property" region to get an idea on how to expose a property.
                      RayNinjaTrader Customer Service

                      Comment


                        #12
                        Hi,

                        I'm sorry but I'm not following you. I believe you mean something like this (in the "properties" section):

                        [Description("Main_SIGNAL")]
                        [Category(
                        "Parameters")]
                        publicdouble The_ROC
                        {
                        get { return The_ROC; }
                        set { The_ROC = EMA(Signal, Sig)[0]; }
                        }

                        However when I attempt to add such commands I get warnings/errors about a possible crash...

                        Thank you.

                        Comment


                          #13
                          Correct, since your code while throw C# for and endless loop. Needed to be:

                          [Description("Main_SIGNAL")]
                          [Category(
                          "Parameters")]
                          publicdouble The_ROC
                          {
                          get { return the_ROC; }
                          set { the_ROC = EMA(Signal, Sig)[0]; }
                          }

                          Note the capitalization

                          Comment


                            #14
                            Thanks for the reply. Why does the "t" at the start of the variable name need to be small case while in the "publicdouble" definition it can be capitalized?

                            Comment


                              #15
                              Unfortunately we are unable to provide support for basic C# programming questions. Please consult the C# docs from Microsoft to understand how C# properties work.

                              Comment

                              Latest Posts

                              Collapse

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