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

Draw 2nd Data Series on Panel 2

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

    Draw 2nd Data Series on Panel 2

    Hi All,
    I am trying to get the second data series onto Panel 2 but have difficulties to implement it.
    Attached a picture to clarify. Any advice what I missed?
    I basically only want the 50 Period of the SPY on the chart on the second panel which currently shows as AAPL. Here my code.

    else if (State == State.Configure)
    {
    AddDataSeries("SPY", Data.BarsPeriodType.Day, 1, Data.MarketDataType.Last);

    _smaSPY = SMA(Closes[1], 50);
    _smaSPY.Plots[0].Width = 2;
    _smaSPY.Plots[0].Brush =Brushes.Purple;
    _smaSPY.Panel = 3;
    base.AddChartIndicator(_smaSPY);
    Attached Files

    #2
    Hello JBU1314, and thank you for your question. You will need to set your indicator or strategy's DrawOnPricePanel setting to true during State.SetDefaults. Please let us know if there are any other ways we can help.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Hi Jessica,
      I did that but I still dont have SPY displayed on Panel 2 jsut the apple as shown in the screen shot attached.

      Comment


        #4
        I misunderstood your intent. In order to do this we have to make a copy of the SMA indicator and override its PanelUI member. I have provided an example.
        Attached Files
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          This is great information. Thank you very much!

          Comment


            #6
            The problem is only that The SMAPanel2 is still showing the primary series (in this example APPL) instead of the SPY which is he secondary Dataseries. So I still do have the same problem. What did i miss?
            Attached Files

            Comment


              #7
              If you would like your strategy to trade on your secondary data series, you can pass in your SPY series to your strategy as shown in the attached image.

              Otherwise, if you would like your strategy to monitor AAPL and your SMA to monitor SPY you will need to modify the code I sent you so that it incorporates your second data series into your SMA indicator, e.g.

              Code:
              [FONT=Courier New] _smaSPY = SMAPanel2([B]BarsArray[1], [/B]Closes[1], 50);[/FONT]
              If neither of these was quite what you were looking for or there is any other way we can help please let us know.
              Jessica P.NinjaTrader Customer Service

              Comment


                #8
                Thank you very much Jessica. This is what I was looking for. I will try to be more specific next time!
                Have a great day!

                Comment


                  #9
                  Jessica, only problem now is that the method in your provided code does only allow for 2 arguments and not 3 as you provided.
                  _smaSPY = SMAPanel2(BarsArray[1], Closes[1], 50);
                  if i adjust to
                  _smaSPY = SMAPanel2(BarsArray[1], 50);
                  I still only have AAPL presented in the SMA Panel.

                  Comment


                    #10
                    Maybe it helps to outline that part of my code again:
                    2 DataSeries APPL & SPY - I want to go long if
                    Close of APPL is above x-Period SMA of APPL
                    AND
                    SMA of SPY is rising (Close[0] > Close[1])
                    AND
                    I also want to see the SMA of SPY on my chart

                    Comment


                      #11
                      I did have a typo present. If you use BarsArray[1] in your SMA, your SMA will be processing over the SPY even if the label shows your primary instrument (AAPL). You can test this by adding another SMA(BarsArray[0]), or adding an SMA indicator on either instrument outside your strategy.
                      Jessica P.NinjaTrader Customer Service

                      Comment


                        #12
                        how can we change the label?

                        Comment


                          #13
                          You can add this to the SMAPanel2 indicator's Properties section

                          Code:
                          [FONT=Courier New]
                                  public string UsedInstrument
                                  { get; set; }
                          
                                  public override string DisplayName
                                  {
                                      get { return "SMA(" + UsedInstrument + ", " + Period + ")"; }
                                  }[/FONT]
                          You will then want to make sure you set this indicator's UsedInstrument manually.
                          Jessica P.NinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by rtwave, 04-12-2024, 09:30 AM
                          2 responses
                          20 views
                          0 likes
                          Last Post rtwave
                          by rtwave
                           
                          Started by tsantospinto, 04-12-2024, 07:04 PM
                          5 responses
                          67 views
                          0 likes
                          Last Post tsantospinto  
                          Started by cre8able, Today, 03:20 PM
                          0 responses
                          6 views
                          0 likes
                          Last Post cre8able  
                          Started by Fran888, 02-16-2024, 10:48 AM
                          3 responses
                          49 views
                          0 likes
                          Last Post Sam2515
                          by Sam2515
                           
                          Started by martin70, 03-24-2023, 04:58 AM
                          15 responses
                          115 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Working...
                          X