• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can't add indicator to indicator

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

    Can't add indicator to indicator

    I would like to add an indicator to an existing indicator. I tried doing this in Initailize()
    Add(SMA(20));,
    but I get an error: Can't convert NinjaTrader.Indicator.SMA to NinjaTrader.GUI.Chart.Line.
    Can someone give me an idea why this won't work?
    Thanks.

    #2
    Hello,

    Thank you for the question.

    In this case, using Add() specifically to add an indicator can only be used from a Strategy.

    If you are adding an indicator using an indicator, you would want to add a Plot instead and then set the Plot from OnBarUpdate to the value of the indicator. This may not produce the desired result in case the indicator has multiple plots, drawing objects or custom rendering.

    The SMA does not have multiple plots, custom rendering or drawing objects so this would be very simple to replot.

    You can use the example of Add to add a Plot: https://ninjatrader.com/support/help...ghlightsub=Add

    Then the remainder of the syntax would just be to add the OnBarUpdate code:

    Code:
    Value.Set(SMA(20)[0]);
    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks Jesse,
      I've been adding indicators in the manner you described for single plot indicators. However now I have an indicator I'd like to add that has multiple plots. I read through the documentation, but I'm still having issues understanding the process. Do you have any sample code for adding a multiple plot indicator? Thanks.

      Comment


        #4
        Hello CaptainAmericaXX,

        A Multi plot indicator is the exact same process, you would just need to define the number of plots that indicator has.

        For example, if you used the Bollinger, you would use Add() 3 times to add 3 new plots. the logic could then look like the following:

        Code:
        protected override void Initialize()
        {
            Add(new Plot(Color.Red, "Upper"));
            Add(new Plot(Color.Blue, "Middle"));
            Add(new Plot(Color.Green, "Lower"));
        }
        
        protected override void OnBarUpdate()
        {
            Values[0].Set(Bollinger(0.5,12).Upper[0]);
            Values[1].Set(Bollinger(0.5,12).Middle[0]);
            Values[2].Set(Bollinger(0.5,12).Lower[0]);
        }
        https://ninjatrader.com/support/help...ightsub=values


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          From my understanding adding plots in this way will add these plots to a separate pane. Is it possible to add these plots, in code, to the price panel?
          I read the DisplayInDataBox() doc. Is there a way to place some lines in the data box and some in an individual pane (NT 7)?
          Last edited by CaptainAmericaXX; 11-15-2017, 02:07 PM.

          Comment


            #6
            Hello CaptainAmericaXX,

            Add will actually use the same panel for all plots that come from a single indicator, only a Strategy would have the capability to add multiple indicators which could be placed in multiple panels.

            If you are using Overlay = false; from the main indicator, the plots would be placed in a new panel, you could instead use Overlay = true; to place all plots from this indicator in the price panel. Please keep in mind if you change this, you would need to remove the indicator from the chart and re-add it instead of just refreshing the chart to see it change.

            regarding the DataBox, it will display specifically Plots. If you only want a Line on the chart, I would suggest using the Drawing tools instead to just draw a Line which will not show up in the DataBox.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Thank you for the help.
              I now have my individual indicator in a separate panel and I'm able to draw on the price panel with DrawOnPricePanel = true, but when I use BackColor I want it to print on the price panel but it is printing in the indicator panel. I am also using a DrawLine() that won't print in the indicator panel but does print in the price panel if I select "same as input series". How might I solve these issues? Thanks.

              Comment


                #8
                Hello CaptainAmericaXX,

                BackColor will affect the panel that the indicator is applied to. If Overlay is set to false, BackColor will be applied to the indicator's own panel. If Overlay is set to true, BackColor will affect the price panel.

                You could accomplish the desired behavior by creating separate indicators for drawing and plotting on the price panel, and another for the indicator panel.

                Please let us know if we can be of further help.
                JimNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Atilla, Yesterday, 04:05 PM
                1 response
                49 views
                1 like
                Last Post im197
                by im197
                 
                Started by vevbarrq, Today, 12:11 AM
                0 responses
                4 views
                0 likes
                Last Post vevbarrq  
                Started by johnnybegoode, Yesterday, 10:16 PM
                0 responses
                4 views
                0 likes
                Last Post johnnybegoode  
                Started by reedstickets, Yesterday, 07:53 PM
                0 responses
                9 views
                0 likes
                Last Post reedstickets  
                Started by Displacer, Yesterday, 02:57 PM
                2 responses
                17 views
                0 likes
                Last Post Displacer  
                Working...
                X