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

NT8 Plot order (zorder)

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

    NT8 Plot order (zorder)

    Hi,

    I'm converting some of my multi plot indicators from 7 to 8. I 7, I have multiple bar plots, but they play nice, i.e. I have the larger one at the back and the smaller values plotted over the top, so you can read both plots even though they are in the same space (different colours).

    With NT8, no matter what order I add the plots in the code, the larger one is always overwriting the other color. I tried the click the plot and shift-mouse wheel thing, but that does not appear to work on indicator plots in nt8?

    How to I tell my code in NT8 that a particular plot should always be behind another plot?

    Thanks,

    #2
    Hello pjsmith,

    There is not a z-order setting for plots. The order of the plots are in the order that they are added by the script in OnStateChange() State.Configure.

    The first added plot will be on the bottom, the last added plot will be on the top.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks. I actually tried that already and it does not seem to work for me. Perhaps I am adding them in the wrong place? If you could look over this part of the code and tell me, I would greatly appreciate it

      Here is my onstatechange

      protected override void OnStateChange()
      {
      if (State == State.SetDefaults)
      {
      Description = @"Enter the description for your new custom Indicator here.";
      Name = "pjsCumDelta";
      Calculate = Calculate.OnEachTick;
      IsOverlay = false;
      DisplayInDataBox = true;
      DrawOnPricePanel = true;
      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;
      BlockFilter1 = 1;
      BlockFilter2 = 1;
      BlockFilter3 = 1;
      ResetOnNewSession = true;
      ShowSessionTotal = true;
      ShowBarTotal = true;
      showDivergence = true;
      showDeltaMomentum = false;
      showHighLow = false;
      showStats = true;
      AddPlot(new Stroke(Brushes.Orange, 2), PlotStyle.Bar, "PlotDMomentum");
      AddPlot(Brushes.Orange, "Plot0balance");
      AddPlot(new Stroke(Brushes.Orange, 2), PlotStyle.Bar, "Plot3barbalance");

      AddPlot(new Stroke(Brushes.Red, 2), PlotStyle.Line, "PlotLow");
      AddPlot(new Stroke(Brushes.Green, 2), PlotStyle.Line, "PlotHigh");

      // Set the pen used to draw the plot as a dashed line
      // Plots[3].Pen.DashStyle = DashStyle.Dash;
      // Plots[4].Pen.DashStyle = DashStyle.Dash;


      }
      else if (State == State.Configure)
      {
      AddDataSeries( Data.BarsPeriodType.Tick, 1);
      }
      }

      PlotDMomentum is the orange bars in the example below. There are red and green bars to. These are smaller values mostly, but the orange bars are blocking them out. I would like the orange bars behind the green and red ones. Changing the order of the plots above does not seem to do this for me. Picture below



      What am I doing wrong?

      Comment


        #4
        Hello pjsmith,

        Adding the plots in the set defaults is fine. The order they are added in should control how they appear (when first added to the chart).

        Have you been making changes to this script?
        When making changes are you removing the instance of the indicator and adding a new instance?

        After the indicator has been applied to the chart, the set defaults is no longer applied. This is why you must remove and re-add the indicator to see how this is defaulting.

        Attached is a simple test script that I've made to test your code and then exported so that this can be shared.

        To export a NinjaTrader 8 NinjaScript do the following:
        1. Click Tools -> Export -> NinjaScript...
        2. Click the 'add' link -> check the box(es) for the script(s) you want to include
        3. Click the 'Export' button
        4. Enter a unique name for the file in the value for 'File name:'
        5. Choose a save location -> click Save
        6. Click OK to clear the export location message

        By default your exported file will be in the following location:
        • (My) Documents/NinjaTrader 8/bin/Custom/ExportNinjaScript/<export_file_name.zip>


        Below is a link to the help guide on Exporting NinjaScripts.



        As a tip, if you want to be able to change the zorder on the fly, this would need to be done in the configure state and the colors would need to be separate public variables. (The plots will no longer appear in the parameters of the Indicator window)
        Attached Files
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Ahhhhhh.... That'll be it. I was not removing from the chart and adding back. I will test later, but this likely is the problem.

          Thanks.

          Comment


            #6
            if reordering plots dont't forget to correct Values[] in properties

            Originally posted by NinjaTrader_ChelseaB View Post
            Hello pjsmith,

            There is not a z-order setting for plots. The order of the plots are in the order that they are added by the script in OnStateChange() State.Configure.

            The first added plot will be on the bottom, the last added plot will be on the top.
            My plots as of jan 2017 are top to bottom as added.

            Comment


              #7
              Hello abdunbar,

              May I confirm you are using 8.0.3.1?

              Are you testing the script I have provided in post #4?
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Barry Milan, Today, 10:35 PM
              0 responses
              2 views
              0 likes
              Last Post Barry Milan  
              Started by DJ888, Yesterday, 06:09 PM
              2 responses
              9 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by jeronymite, 04-12-2024, 04:26 PM
              3 responses
              40 views
              0 likes
              Last Post jeronymite  
              Started by bill2023, Today, 08:51 AM
              2 responses
              16 views
              0 likes
              Last Post bill2023  
              Started by sidlercom80, 10-28-2023, 08:49 AM
              167 responses
              2,260 views
              0 likes
              Last Post jeronymite  
              Working...
              X