Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plotting on different panel

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

    Plotting on different panel

    Ok I'm using the help example on AddPlot of adding 3 Value series. The resulting plot overlays it on the main price data panel. I would like to plot them on a separate panel. How do I do that? Also does it autoscale the plot?

    protected override void OnStateChange()
    {
    * if (State == State.SetDefaults)
    * {
    * * Name = "Examples Indicator";
    *
    * * // Add three plots and associated Series<double> objects
    * * AddPlot(Brushes.Blue, "PlotA"); * * // Defines the plot for Values[0]
    * * AddPlot(Brushes.Red, "PlotB"); * * // Defines the plot for Values[1]
    * * AddPlot(Brushes.Green, "PlotC"); * // Defines the plot for Values[2]
    * }
    }
    protected override void OnBarUpdate()
    {
    * Values[0][0] = Median[0]; * // Blue "Plot A"
    * Values[1][0] = Low[0]; * * * // Red "Plot B"
    * Values[2][0] = High[0]; * * // Green "Plot C"
    }

    #2
    Hello DuggyLou,

    Thanks for opening the thread.

    Indicators can draw to additional panels as well as the main price panel, while strategies can only plot directly to the main price panel.

    If you would like to add plots to the indicator panel, you will have to create an indicator that plots these values to the indicator panel by using the DrawOnPricePanel bool. You can then add that indicator to your strategy using the AddChartIndicator() method.

    DrawOnPricePanel - https://ninjatrader.com/support/help...pricepanel.htm

    AddChartIndicator() - https://ninjatrader.com/support/help...tindicator.htm

    Please let me know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      Ok since I'm calling this from a strategy it's plotting it in the main price panel. I don't have an indicator that describes the function I'd like to plot. So say I have a variable "Y1" which is some function that is calculated on each call of OnBarUpdate . How would I convert that into an indicator so I could plot it as such?

      Here is my first try. But it's not working yet. It's just showing a blank plot at the bottom.

      public class MyCustomIndicator : Indicator
      {
      private TRIX TRIX1;

      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      Description = @"Enter the description for your new custom Indicator here.";
      Name = "MyCustomIndicator";
      Calculate = Calculate.OnBarClose;
      IsOverlay = false;
      DisplayInDataBox = true;
      DrawOnPricePanel = false;
      DrawHorizontalGridLines = true;
      DrawVerticalGridLines = true;
      PaintPriceMarkers = true;
      ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
      //Disable this property if your indicator requires custom values that cumulate with each new market data event.
      //See Help Guide for additional information.
      IsSuspendedWhileInactive = true;
      TPeriod = 1;
      AddPlot(Brushes.Orange, "YValue");
      }
      else if (State == State.Configure)
      {
      AddDataSeries(Data.BarsPeriodType.Minute, 1);
      }
      else if (State == State.DataLoaded)
      {
      TRIX1 = TRIX(Closes[1], TPeriod, 3);
      }
      }

      protected override void OnBarUpdate()
      {
      //Add your custom indicator logic here.

      Values[0][0] = TRIX1[0];
      }
      Last edited by DuggyLou; 04-26-2017, 12:13 PM.

      Comment


        #4
        Hello DuggyLou.

        Thanks for your additional question.

        You can use the code you have referenced in your first post to make multiple plots from an indicator.

        You would then need to add the appropriate logic for how you calculate the value for Y1.

        If you are plotting this value you can access it from your strategy like you do for other plots.

        If you do not wish to plot this value, you can still expose it so you can access this value from your strategy.

        We offer a reference sample that demonstrates how to expose a Series or a variable from an indicator and how to reference it in a strategy. I will provide a link below:

        http://ninjatrader.com/support/forum...ead.php?t=4991

        Please let me know if I may be of further assistance.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by WeyldFalcon, Today, 02:07 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_ThomasC  
        Started by hfwiley, Today, 03:02 PM
        2 responses
        15 views
        0 likes
        Last Post hfwiley
        by hfwiley
         
        Started by pdennis, Today, 02:34 PM
        3 responses
        15 views
        0 likes
        Last Post NinjaTrader_ChrisL  
        Started by tonynt, Today, 01:47 PM
        3 responses
        17 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by WesFoster, Today, 12:39 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Dennis  
        Working...
        X