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

Z-Order

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

    Z-Order

    I have a custom SMA indicator and found some code else ware that can set the Z-Order behind candle bars but have no coding experience and was wondering if someone here could help out?

    I have 6 MA's on each chart and is time consuming to have to change them in the morning manually!

    Indicator is attached!

    Here is the code

    #region Variables

    private bool zOrderBehind = false;

    private int CatchZOrder;
    ----------------------------------------------------
    protected override void Initialize()

    CatchZOrder = ZOrder;
    ----------------------------------------------------
    protected override void OnStartUp()
    {
    CatchZOrder = ZOrder;
    }
    ----------------------------------------------------
    protected override void OnBarUpdate()

    {
    if(zOrderBehind == true)ZOrder = -1;
    if(zOrderBehind == false)ZOrder = CatchZOrder;
    }
    ------------------------------------------------------------------
    #region Properties

    [Description("Draw Price Lines Behind Bars")]
    [Category("Display Settings")]
    [Gui.Design.DisplayName ("Draw Price Lines Behind Bars")]
    public bool ZOrderBehind
    {
    get { return zOrderBehind; }
    set { zOrderBehind = value;}
    }
    Someone else put this up

    In the end I came up with ZOrder = int.MaxValue; on Initialize()
    This allows and indeed worked to put plots in front of candles but on top of that, it will also manage to set the proper order between numerous indicator installations...

    The opposite is ZOrder = int.MinValue;
    What I think is happening here is he wants it on top and I want it behind bars!

    Also is there an indicator that would do this for all indicators and drawing tools used?

    Cheers
    Attached Files
    Last edited by geotabs; 10-09-2020, 03:44 PM.

    #2
    Hello geotabs, thanks for your post.

    Each one of the indicators needs to call:

    SetZOrder(-1);

    in the Initialize method. If every indicator has this in the Initialize() method every plot will be behind the bars. If you want this to be configurable through user input, please test setting the SetZOrder() method within OnStartup.

    Please let me know if this does not resolve your inquiry.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChrisL View Post
      Hello geotabs, thanks for your post.

      Each one of the indicators needs to call:

      SetZOrder(-1);

      in the Initialize method. If every indicator has this in the Initialize() method every plot will be behind the bars. If you want this to be configurable through user input, please test setting the SetZOrder() method within OnStartup.

      Please let me know if this does not resolve your inquiry.
      Thanks for the response Chris but like I stated I don't code or know anyone that does so this is like trying to read something in a language I don't know.
      That's why I'm asking for help in the indicator development.

      Sorry if this is the wrong area to post this.

      Comment


        #4
        Hi @geotabs

        I have never used NT7, don't have it, and know absolutely nothing about it, .. zero NT7 skills so cant be much help..

        " 1) If every indicator has this in the Initialize() method every plot will be behind the bars.
        2) If you want this to be configurable through user input, please test setting the SetZOrder() method within OnStartup "

        What Chris wrote looked maybe fast and easy enough so I took a few wild guesses and try just to code up my read of what Chris posted above.


        I have no idea if the attached update produces compiler errors, and without NT7 can not test it.

        This is probably just a first step but Chris could help you get it right from this point pretty fast if you report back what did and did not work.


        The edits attempt to give you the ability to test both options Chris stated above.

        Code:
        //
        
        
        
        protected override void Initialize()
        {
        Add(new Plot(Color.Orange, "SMA"));
        
        /// Remove or add back the two 'slash" characters at the front of the line below to turn this
        /// feature on or off in "Initialize."
        
        /// Initialliy the "//" slashes are included so the feature starts out turned "OFF" in Initialize()
        SetZOrder(zorder);
        
        ....
        }
        
        
        protected override void OnStartUp()
        {
        
        /// Remove or add back the two 'slash" characters at the front of the line below to turn this
        /// feature on or off in "Initialize"
        
        /// Initialliy the "//" slashes were deleted so the feature is turned "ON" in OnStartUp()
        SetZOrder(zorder);
        
        ....
        
        #region Properties
        
        [Description("Zorder")]
        public int Zorder // added
        {
        get { return zorder; }
        set { zorder = Math.Min(-1, value); }
        }
        
        #endregion Properties
        //
        Just an FYI .. the good folks over at https://futures.io/ have a ~" free help with NT7 indicators" thread and sometimes help with NT7 indicators.


        Cheers!

        HedgePlay
        Attached Files

        Comment


          #5
          Originally posted by hedgeplay View Post
          Hi @geotabs

          I have never used NT7, don't have it, and know absolutely nothing about it, .. zero NT7 skills so cant be much help..

          " 1) If every indicator has this in the Initialize() method every plot will be behind the bars.
          2) If you want this to be configurable through user input, please test setting the SetZOrder() method within OnStartup "

          What Chris wrote looked maybe fast and easy enough so I took a few wild guesses and try just to code up my read of what Chris posted above.


          I have no idea if the attached update produces compiler errors, and without NT7 can not test it.

          This is probably just a first step but Chris could help you get it right from this point pretty fast if you report back what did and did not work.


          The edits attempt to give you the ability to test both options Chris stated above.

          Code:
          //
          
          
          
          protected override void Initialize()
          {
          Add(new Plot(Color.Orange, "SMA"));
          
          /// Remove or add back the two 'slash" characters at the front of the line below to turn this
          /// feature on or off in "Initialize."
          
          /// Initialliy the "//" slashes are included so the feature starts out turned "OFF" in Initialize()
          SetZOrder(zorder);
          
          ....
          }
          
          
          protected override void OnStartUp()
          {
          
          /// Remove or add back the two 'slash" characters at the front of the line below to turn this
          /// feature on or off in "Initialize"
          
          /// Initialliy the "//" slashes were deleted so the feature is turned "ON" in OnStartUp()
          SetZOrder(zorder);
          
          ....
          
          #region Properties
          
          [Description("Zorder")]
          public int Zorder // added
          {
          get { return zorder; }
          set { zorder = Math.Min(-1, value); }
          }
          
          #endregion Properties
          //
          Just an FYI .. the good folks over at https://futures.io/ have a ~" free help with NT7 indicators" thread and sometimes help with NT7 indicators.


          Cheers!

          HedgePlay
          Thanks but did get some compiling errors as attached

          Thanks for the help!
          Attached Files

          Comment


            #6
            What I eneded up doing was using ZOrder = -1; in
            protected override void Initialize()

            It does put them behind bars!

            But for some reason it doesn't let me double click on the SMA to bring up the properties window?

            Any ideas

            Comment


              #7
              Hi geotabs,

              As I mentioned above I don't use or know NT7 and will let Chris or others provide answers.

              I just wanted to acknowledge that your post above seems to be the type that gets the most response from the NT team.
              • [*=1]You are actively driving the development and debug of your code. [*=1]You have gotten further than the previous post. [*=1]You hit a specific next steps barrier or surfaced a specific next steps question you would like some help
              Good show.


              In the post above to me it is not perfectly clear what you want as a result of your post.
              Is it "How do test to debug or make changes so that I can, like with my other indicators, double click on my new indicator and have the properties window appear?"

              A repost with a more direct crisp clear question or request might get a faster response from the NT team.

              Comment


                #8
                Hello geotabs, thanks for your reply.

                I must apologize for not checking this first, SetZOrder is a NinjaTrader 8 only method. I tested setting ZOrder as well but it seems this property is already set on the chart after Initialize is called. Set the property in OnStartUp instead:

                protected override void OnStartUp()
                {
                ZOrder = -1;
                }


                Chris L.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_ChrisL View Post
                  Hello geotabs, thanks for your reply.

                  I must apologize for not checking this first, SetZOrder is a NinjaTrader 8 only method. I tested setting ZOrder as well but it seems this property is already set on the chart after Initialize is called. Set the property in OnStartUp instead:

                  protected override void OnStartUp()
                  {
                  ZOrder = -1;
                  }

                  So this doesn't go in
                  protected override void Initialize()
                  cause that's where I have it now.

                  Is this why I'm not able to double click on SMA to bring up properties window?

                  Thanks

                  Comment


                    #10
                    Hello geotabs, thanks for your reply.

                    Changing the ZOrder was never officially supported in NinjaTrader 7, so this could be a side effect of changing the z order. It can be tested by removing the code you suspect is causing the problme and running the indicator again.

                    Best regards.
                    Chris L.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by cmtjoancolmenero, Yesterday, 03:58 PM
                    11 responses
                    38 views
                    0 likes
                    Last Post cmtjoancolmenero  
                    Started by FrazMann, Today, 11:21 AM
                    0 responses
                    3 views
                    0 likes
                    Last Post FrazMann  
                    Started by geddyisodin, Yesterday, 05:20 AM
                    8 responses
                    52 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by DayTradingDEMON, Today, 09:28 AM
                    4 responses
                    26 views
                    0 likes
                    Last Post DayTradingDEMON  
                    Started by George21, Today, 10:07 AM
                    1 response
                    22 views
                    0 likes
                    Last Post NinjaTrader_ChristopherJ  
                    Working...
                    X