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 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, 01: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:



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

        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