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

Using Custom Indicator in Strategy Builder

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

    Using Custom Indicator in Strategy Builder

    Hello,
    How can I use a custom indicator that I've created through the editor in Strategy Builder? Is there something I could to add to the indicator code?

    Thanks.

    #2
    Hello KINGKODA,

    Thanks for your post.

    The strategy builder would look for any plot that the indicator provides.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thanks Paul,

      The two options I found are:
      AddPlot(Brush brush, "string name") and AddPlot(Stroke stroke, PlotStyle plotStyle, "string name")

      How do I plot a private.double.variable within my indicator?

      I have private double high & private double low... How can I add Value Plot as shown in the attached picture so that my high and low variables show in the drop down list?
      Attached Files

      Comment


        #4
        Hello KINGKODA,

        Thanks for your reply.

        I've created and attached a simple indicator that creates a single plot and I've used an SMA(10) as the input to that plot. You can certainly use any input to test this out.

        I've also attached a screenshot of what it would look like in the strategy builder.

        Please observe that the code for the one plot consists of 3 parts, the first part is the AddPlot() statement in OnstateChange inside of Set.Defaults. The 2nd part is in the OnBarUpdate() where a double value (in this example an SMA(10)[0]) is assigned to the plot. Finally in the #region properties where the plot name is tied to the Values[0] for plotting as well as making publically accessible.

        With your indicator would need to add two plots. Please note the plot properties in the example indicators #region properties. See how the name of the plot is tied to Values[0]. You will need to have two of these in your indicator, one for Values[0] (the first plot you add) and the other would be Values[1] for the second plot you add.

        When you using your indicator in the strategy builder, you can only select one plot or the other per condition and this is what is meant by "value plot". You can, of course, have multiple conditions.

        Also, in case you prefer to not see the plots on the chart (if applied to the chart), you can always set the plot to transparent and it will continue to function in the strategy.
        Attached Files
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Thanks again Paul,

          I attached an example indicator following your instructions for Part 1, 2 and 3 and I added comment lines because I seem to be doing something wrong but not sure what.

          The main issue seems to be under #region properties, the error code says that it already contains a definition for hi & lo.

          I don't care about the color of the plot as much as I care about the ability to choose between hi and lo under plots in SB. I understand that per condition I can only use one value, but I need a choice under plots.
          Attached Files

          Comment


            #6
            Hello KINGKODA,

            Thanks for your reply.

            As you have used AddPlot to create plots (which are data series) called hi and one called lo, your private declarations of these as only doubles on line 29 & 30 are not needed and should be removed.

            To assign a value to a plot you have to use the bar index, so where you have hi = High[0], you would need to use hi[0] = High[0] and likewise for low.

            Finally, in the region properties, you need to change the second Values from Values[0] to Values[1].

            I do not know how you intend to use these in the Strategy builder but keep in mind that you are assigning values to these plots ONLY when your condition is true, IE: if (High[0] > High[1])
            {hi[0] = High[0];}
            This means that these plots will have period of no values.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Got it.

              Thank you Paul for all your help... Much appreciated!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by GLFX005, Today, 03:23 AM
              0 responses
              1 view
              0 likes
              Last Post GLFX005
              by GLFX005
               
              Started by XXtrader, Yesterday, 11:30 PM
              2 responses
              11 views
              0 likes
              Last Post XXtrader  
              Started by Waxavi, Today, 02:10 AM
              0 responses
              6 views
              0 likes
              Last Post Waxavi
              by Waxavi
               
              Started by TradeForge, Today, 02:09 AM
              0 responses
              11 views
              0 likes
              Last Post TradeForge  
              Started by Waxavi, Today, 02:00 AM
              0 responses
              2 views
              0 likes
              Last Post Waxavi
              by Waxavi
               
              Working...
              X