Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

State.Terminated and ChartControl

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

    State.Terminated and ChartControl

    Hi!
    Please clarify, is it a bug or intended behavior: in the NT7 when OnTermination() was called I could operate with ChartControl object (I removed my custom objects added to the ChartControl). It worked perfectly fine for reloading script and for loadiing Template with my script. But when I tried to implement the similar with NT8 I have discovered that at the State == State.Terminated the object ChartControl is available for reloading script but does not exist when I am loading Template with my script. Is it a bug?
    Last edited by AlexGn; 11-10-2015, 05:48 AM.

    #2
    Hello,

    Thank you for the question.

    I wanted to get further detail on what exactly is occurring here. From what I read, you have a custom item using ChartControl and upon applying a chart template, reloading the NinjaScript does not allow use of ChartControl because it is null. Is this correct?

    Could you provide a simple example of your usage of ChartControl and the steps you are using to re create this so I can further test on my end?

    I am unsure if this would or would not be expected at this point, first I would need to re create it as you have to see the steps that produced the null control.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,

      Thank you for your attention. I beleive you are correct with only one clarification: all of that about Terminated state. Below is the example as you asked:
      Code:
          public class example : Indicator
          {
              protected override void OnStateChange()
              {
                  if (State != State.Terminated)
                  {
                      Print(State.ToString());
                  }
                  else if (State == State.Terminated)
                  {
                      Print(State.ToString());
                      if (ChartControl == null)
                      {
                          Print("ChartControl is NULL");
                          return;
                      }
                      Print("ChartControl is not null");
                   }
              }
          }
      And what I do (usecase 1):
      1. Apply this indicator to the chart
      2. Reload script (F5)
      - Everything is fine and ChartControl is not null in the Terminated state

      Then (usecase 2):
      1. Apply this indicator to the chart
      2. Save Chart as Template
      3. Load template
      - ChartControl is null and not available in the Terminated state

      The similar script works fine for both usecases in the NT7, iow ChartControl is always available in OnTermination() function

      Comment


        #4
        Hello,

        Thank you for the details and your test. I believe this would be expected from the process outlined.

        Looking at the actions that occur when applying the indicator to a chart initially would be the same as applying a template.

        The output I see with your test when applying on a chart:

        Terminated
        ChartControl is NULL

        The last state we see as it was terminated, it was null and would be expected, when you reload the chart because it is already on the chart, it should no longer be null.

        In your test I see when applying the template the same null print, this would again be expected as it is a fresh indicator being applied.

        ChartControl would be expected to be null and not null at different points in a scripts life or depending on where it is called from also.

        Can you tell me, in your full script, are you currently using something where this is posing a problem for you somehow? In general, so long as you are checking if the ChartControl is null or not, there should be no issues with this. Can you provide more details on if there is an actual problem you are facing, currently this seems to be expected and would be resolved by checking if the control is null.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Jesse,

          Thanks for the explanation. I am just confused why NT7 has different behavior. Or I am missing something. Please try following code in the NT7:
          Code:
              public class example : Indicator
              {
                  protected override void Initialize()
                  {
                      return;
                  }
          
                  protected override void OnTermination()
                  {
                      Print("OnTermination call");
                      if (ChartControl == null)
                      {
                          Print("ChartControl is NULL");
                          return;
                      }
                      Print("ChartControl is not null");
                  }
                  protected override void OnBarUpdate()
                  {
                      return;
                  }        
              }
          In my understanding this the same as I did for NT8 and posted earlier. But this script works differently. For both usecases (reloading chart or applying template) ChartControl is always available. So why it should work different way in the NT8 I do not understand.

          As to the my particular problem. At Configure state I add my custom handlers to Chart Panel and my custom Buttons to the menu. At the Terminated state I remove them. And it works perfectly fine for reloading script (and in NT7 for any cases), but in NT8 for applying template case I cannot remove them because ChartControl is unavailable. So handlers cannot be removed and on each template applying new buttons are created (without removing old ones).
          Please inform me if it is not detailed enough and you need some another info.
          Thanks again for you help!

          Comment


            #6
            Hello,

            Thank you for the reply.

            This is quite enough detail to understand the situation, unfortunately I was unable to re create this in my own test. Would you be able to provide a simple example that demonstrates this occurring with a single button?

            If there is an underlying issue I could pass that on to development for further review.

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

            Comment


              #7
              Hi Jesse,

              I have attached the script to demostrate my particular issue. Hope it helps. And thanks!
              Attached Files

              Comment


                #8
                Hello,

                Thank you for providing the file to test.

                I did see that the button does not get removed when re applying the template. I am currently working with Product management to find if this would be outside of what is expected.

                I look forward to being of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Hi Jesse,

                  Any update on this?
                  BTW, I would ask you to bring in Product management attention that oficially supported and provided example how to work with buttons (http://ninjatrader.com/support/helpG...th_buttons.htm) has the same issue (at least I can reproduce it).

                  Comment


                    #10
                    Originally posted by AlexGn View Post
                    Any update on this? BTW, I would ask you to bring in Product management attention that oficially supported and provided example how to work with buttons (http://ninjatrader.com/support/helpG...th_buttons.htm) has the same issue (at least I can reproduce it).
                    I would revisit your code again, as I use buttons for everything and am not experiencing the problem you described.. Created a new blank chart, loaded a saved template, and everything seems to be working fine..




                    Attached Files
                    -=Edge=-
                    NinjaTrader Ecosystem Vendor - High Tech Trading Analysis

                    Comment


                      #11
                      We were able to identify a scenario where chart control was null when an indicator was preloaded on a chart and you attempted to loaded a chart template which contained the same indicator. This will be fixed in #9108

                      As far as the issue with the documentation, I'm not able to reproduce any problems related to what you're discussing in this thread. If you have the steps without the template variable which could be at play until B7, please let us know.
                      MatthewNinjaTrader Product Management

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Jon17, Today, 04:33 PM
                      0 responses
                      1 view
                      0 likes
                      Last Post Jon17
                      by Jon17
                       
                      Started by Javierw.ok, Today, 04:12 PM
                      0 responses
                      5 views
                      0 likes
                      Last Post Javierw.ok  
                      Started by timmbbo, Today, 08:59 AM
                      2 responses
                      10 views
                      0 likes
                      Last Post bltdavid  
                      Started by alifarahani, Today, 09:40 AM
                      6 responses
                      41 views
                      0 likes
                      Last Post alifarahani  
                      Started by Waxavi, Today, 02:10 AM
                      1 response
                      20 views
                      0 likes
                      Last Post NinjaTrader_LuisH  
                      Working...
                      X