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

is it MUST that SetZOrder was in State.Historical?

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

    is it MUST that SetZOrder was in State.Historical?

    docs say - https://ninjatrader.com/support/help...?setzorder.htm

    that setzorder should be executed once state reachs Historical.

    will the same result achieved if i use it in DataLoaded, instead of Historical?

    #2
    Hello TazoTodua, thanks for your post.

    I modified the SampleMACrossover script and this z-order setting worked for me, so you can do this in DataLoaded:

    Code:
    else if (State == State.DataLoaded)
                {
                    smaFast = SMA(Fast);
                    smaSlow = SMA(Slow);
    
                    smaFast.Plots[0].Brush = Brushes.Goldenrod;
                    smaSlow.Plots[0].Brush = Brushes.SeaGreen;
    
                    smaFast.SetZOrder(-1);
                    smaSlow.SetZOrder(-2);
    
                    AddChartIndicator(smaFast);
                    AddChartIndicator(smaSlow);
                }
    I will check in with our product management team to see why the HG says to set it in State.Historical, we might be able to change that to DataLoaded.

    Kind regards.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hello TazoTodua,

      It looks like it is recommended to set z-order in State.Historical to avoid interference with other scripts that set their own z order. An example of where your ZOrder wouldn't refresh is adding a new series to chart -> All the other indicators will refresh ZOrder but your ZOrder will not change, meaning now your indicator is rendering at a different Z-index in relation to the other indicators = Now your indicator is drawing on top of stuff is shouldn't be, etc.
      Chris L.NinjaTrader Customer Service

      Comment


        #4
        Setting ZOrder in State.Historical or State.DataLoaded does not make sense to me.

        Example: I have an indicator that uses a custom render section to draw the plots and shade the area between the plots. Obviously, I do not want to have the shading on top of the price bars. Therefore I have used SetZOrder(-1) in State.Historical to make sure that the shading is behind the bars.

        However, some of the users do not use the shading and wish the plots to show on top of the price bars. These users modify the ZOrder of the indicator by selecting the indicator plot and then press the SHIFT button and turn the mouse wheel. Afterwards they save chart and workspace as templates. Unfortunately, when they do so, the ZOrder of the indicator will not be stored with the templates, but the indicator will reappear behind the bars when the chart template or workspace is loaded. This is not what the user expects, as the ZOrder of the NinjaTrader in-built indicators will be remembered and correctly loaded.

        When ZOrder is set in State.Configure, State.DataLoaded or State.Historical, the user cannot modify the ZOrder and store the modified ZOrder as part of a chart template or workspace.

        Therefore the only logical place to set the ZOrder in an indicator is State.SetDefaults(). When SetZOrder(-1) is added to State.SetDefaults(), any user made changes to the ZOrder will be stored in a chart template or workspace as expected.

        My questions:

        (1) Would you agree that State.SetDefaults() is the correct location to set the ZOrder?
        (2) In case that you agree, would you please modify the Help Guide to show that SetZOrder() should be used in State.SetDefaults() and not in State.Historical()?
        (3) In case that you disagree, how would I handle setting the ZOrder programmatically in such a way that a user can change it and save changes in a chart template or workspace?

        Comment


          #5
          Hello Harry, thanks for your post.

          It's fine to put your SetZOrder in SetDefaults. The only caveat will be if the user adds another series to the chart, the user would need to adjust the z-order after that. I will add a suggestion to add this bit of info to the help guide.
          Chris L.NinjaTrader Customer Service

          Comment


            #6
            Originally posted by NinjaTrader_ChrisL View Post
            Hello Harry, thanks for your post.

            It's fine to put your SetZOrder in SetDefaults. The only caveat will be if the user adds another series to the chart, the user would need to adjust the z-order after that. I will add a suggestion to add this bit of info to the help guide.

            Hello Chris, thank you for your answer.

            I perfectly understand that the user may need to adjust the z-order after adding an indicator. However, this is as expected.

            What is not expected is that the indicator does not maintain its z-order when being saved as part of a chart template or workspace.

            Users are unnerved, when they have to readjust the z-order manually every time after they open a workspace!

            The lesser evil is - by far - setting the z-order in SetDefaults().

            Comment


              #7
              I am regularly dealing with customers who complain that the z-order cannot be stored via chart template or workspace.

              This is because many indicators have set the z-order via SetZOrder in State.Historical as explained in the help guide.

              May I kindly ask that you provide correct information in the help guide that SetZOrder should be used in State.SetDefaults.

              In that case it works as expected, and the z-order can be saved via chart template and workspace.

              Please modify the help file and you will have fewer customer complaints!

              Comment


                #8
                Hi Harry, thanks for the follow up.

                I have created a request to our product management team. I was sure to stress details on the problems your clients are having.
                Chris L.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by cre8able, 02-11-2023, 05:43 PM
                3 responses
                236 views
                0 likes
                Last Post rhubear
                by rhubear
                 
                Started by frslvr, 04-11-2024, 07:26 AM
                8 responses
                113 views
                1 like
                Last Post NinjaTrader_BrandonH  
                Started by stafe, 04-15-2024, 08:34 PM
                10 responses
                46 views
                0 likes
                Last Post stafe
                by stafe
                 
                Started by rocketman7, Today, 09:41 AM
                3 responses
                11 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by traderqz, Today, 09:44 AM
                2 responses
                10 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Working...
                X