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

Plotting the same indicator twice within the same code?

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

    Plotting the same indicator twice within the same code?

    I would like to be able to code the following;

    I maually plot the same indicator on the same chart to give the effect of a center line. That is I plot a 13 SMA line with a 20 Pen size in Yellow and a 13 SMA line with a 1 Pen size in Black.
    I have tried plotting both of these lines within a custom indicator I coded, but it will only plot one line not both. Is it possible to Plot the same 13-SMA line within the code of custom indicator?

    Thank You Very Much in Advance.

    #2
    Hello jmca2000,

    Thank you for your post.

    It is possible to have multiple plots within the same indicator. An example of multiple plots can be taken from the Bollinger indicator in NinjaTrader under Tools > Edit NinjaScript > Indicator > Bollinger.

    Comment


      #3
      Patrick, Thank You for your quick response, I think and hope you might have misunderstood my question...

      I believe the Bollinger Bands plot correctly because the coordinates for there lines are at different locations, unlike plotting the same SMA period indicator twice within the same indicator code because the plot coordinates for the SMA's would be the same?

      I'm following the same coding method as the Bollinger Bands;

      Code:
       Add(PeriodType.Range, 8);
        
       Add(new Plot(new Pen (Color.FromKnownColor(KnownColor.Yellow), 20), PlotStyle.Line, "PlotSMA1"));
      
       Add(new Plot(new Pen (Color.FromKnownColor(KnownColor.Black), 1), PlotStyle.Line, "PlotSMA2"));
        
       protected override void OnBarUpdate()
      {
       PlotSMA1.Set(LinReg(BarsArray[1], 13) [0] );
      PlotSMA2.Set(LinReg(BarsArray[1], 13) [0] );
       }
        
       [Browsable(false)]
      [XmlIgnore()]
      public DataSeries PlotSMA1
      {
      get { return Values[0]; }
      }
       [Browsable(false)]
      [XmlIgnore()]
      public DataSeries PlotSMA2
      {
      get { return Values[1]; }
      }
      If this is the case, how come they can be plotted manually but not within a code script?

      Thanks again in advance Joe.

      Comment


        #4
        Hello jmca2000,

        Thank you for your response.

        This is because they are being plotted on top of each other when called from the code.

        Comment


          #5
          Originally posted by jmca2000 View Post
          I would like to be able to code the following;

          I maually plot the same indicator on the same chart to give the effect of a center line. That is I plot a 13 SMA line with a 20 Pen size in Yellow and a 13 SMA line with a 1 Pen size in Black.
          I have tried plotting both of these lines within a custom indicator I coded, but it will only plot one line not both. Is it possible to Plot the same 13-SMA line within the code of custom indicator?

          Thank You Very Much in Advance.
          NinjaTrader's Plot() does not seem to consistently layer multiple Plots. Either manually adjust the Plot z-orders or else use a custom Plot, where you can effectively control the Plots, so that the thinner Plot is the top one. That way you can see both Plots.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by cls71, Today, 04:45 AM
          0 responses
          1 view
          0 likes
          Last Post cls71
          by cls71
           
          Started by mjairg, 07-20-2023, 11:57 PM
          3 responses
          213 views
          1 like
          Last Post PaulMohn  
          Started by TheWhiteDragon, 01-21-2019, 12:44 PM
          4 responses
          544 views
          0 likes
          Last Post PaulMohn  
          Started by GLFX005, Today, 03:23 AM
          0 responses
          3 views
          0 likes
          Last Post GLFX005
          by GLFX005
           
          Started by XXtrader, Yesterday, 11:30 PM
          2 responses
          12 views
          0 likes
          Last Post XXtrader  
          Working...
          X