Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Show two indicators in same DataBox

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

    Show two indicators in same DataBox

    I use the following in my Strategy.Initialize():

    Code:
    			Add(ROC(10));
    			Add(ROC(20));
    By default each indicator gets its own separate chart panel.

    I want to code these two ROC lines to display in the same panel, using the same y axis. What's the easiest way to do that?
    Last edited by dbooksta; 06-03-2014, 05:59 PM.

    #2
    Hello dbooksta,

    To have both plots in the same section of the Data Box you will need to recode the indicator to have two plots each with a different period value.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      I've been playing with this and it seems there should be another workaround. For example, by hand after the backtest has been run the chart indicators can be edited and the ROC indicators can be assigned to the same Panel.

      If I add the following code to Initialize() they are also displayed in the same Panel,
      Code:
      			ROC(20).Panel = 2;
      			ROC(10).Panel = 2;
      but when the chart is rendered they are displayed together in Panel #3 and Panel #2 is blank.

      So there must be another function or event handler called after Initialize that reformats things, and we just need to assign them to the same panel there. Or else find code that will hide Panel 2.
      Last edited by dbooksta; 06-03-2014, 04:03 PM.

      Comment


        #4
        Hi dbooksta,

        I had thought there were some issues with this, but it seems doable.

        Attached is a sample. Let me know if this is not what you are trying to do.
        Attached Files
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I couldn't get your sample to run to completion.

          But attached is a screenshot that shows the problem. Just add the following lines to the SampleMACrossOver strategy and backtest it to reproduce the attached backtest chart with its superfluous empty Panel #2:
          Code:
          			ROC(Fast).Plots[0].Pen.Color = Color.Blue;
          			ROC(Slow).Plots[0].Pen.Color = Color.Maroon;
          			ROC(Fast).Panel = 2;
          			ROC(Slow).Panel = 2;
          			Add(ROC(Fast));
          			Add(ROC(Slow));
          Attached Files

          Comment


            #6
            Hello dbooksta,

            The sample I created does not make any trades. It simply adds the SMA(20) and SMA(10) to your script and they should both be in the same panel.

            Are you unable to import the script? Are you getting an error message when you try and run?

            (I can assure you that I tested this script and it is adding the two plots on my end OK).
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ChelseaB View Post
              Hello dbooksta,

              The sample I created does not make any trades. It simply adds the SMA(20) and SMA(10) to your script and they should both be in the same panel.

              Are you unable to import the script? Are you getting an error message when you try and run?

              (I can assure you that I tested this script and it is adding the two plots on my end OK).
              After a restart it imported and ran. But I don't see how this addresses the question and problems raised in this thread. By default any number of moving average indicators can be added to a Strategy and they all display in the chart's price panel.

              Your sample's StrategyPlot indicator does not appear able to put the SMA plots in a separate panel. E.g., I would have hoped for something like this to alter its behavior, but it doesn't:

              Code:
              			StrategyPlot(SMA(20), 0).Panel = 2;
              			StrategyPlot(SMA(10), 1).Panel = 2;

              Comment


                #8
                Hi dbooksta,

                I had miss understood. I had thought you were trying to add the indicators to the primary panel....

                Try this instead, this adds to a secondary panel.
                Attached Files
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Thanks. So in conclusion: all we have to do is set the Indicator's .PanelUI property (not .Panel)to the desired panel number.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by timmbbo, Today, 08:59 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post timmbbo
                  by timmbbo
                   
                  Started by bmartz, 03-12-2024, 06:12 AM
                  5 responses
                  33 views
                  0 likes
                  Last Post NinjaTrader_Zachary  
                  Started by Aviram Y, Today, 05:29 AM
                  4 responses
                  13 views
                  0 likes
                  Last Post Aviram Y  
                  Started by algospoke, 04-17-2024, 06:40 PM
                  3 responses
                  28 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Started by gentlebenthebear, Today, 01:30 AM
                  1 response
                  8 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Working...
                  X