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

Chart refresh

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

    Chart refresh

    Hi ... I used "ChartControl.ChartPanel.Invalidate();" to force a screen refresh in NT7 ... what is the equivalent in NT8?

    #2
    Hello,

    Thank you for the post.

    In NT8 it is not suggested to try and invalidate any control, this is due to the multithreading in the platform. You can create crash situations if you do try to invalidate controls.

    Instead, you have a couple of options, to inform the chart that a refresh may be needed, ForceRefresh is suggested:


    To immediately repaint a chart, you would need to cause one of the actions listed on the ForceRefresh page. The only action that can be directly invoked would be to add a dummy drawing object and then immediately remove it. You can use the Draw. methods to draw a Dot as an example, the dot can be transparent not scaled at a price of 0, and then the next line of code can be its removal. This would be useful for a case that requires a update which is out of event, for example, a button press.



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

    Comment


      #3
      I checked ForceRefresh ... 250ms is too long of a delay. So, to clarify, to get an immediate refresh, execute a "Draw.Dot" commend, then "Remove" it right away ... correct?

      Comment


        #4
        Hello,

        Correct. The object being added and removed is only a step to cause the refresh, because the chart is looking for an object to be removed this would cause a refresh.

        The syntax could be as simple as the following:
        Code:
        Draw.Dot(this, "dummy_dot", false, 0, 0, Brushes.Transparent);
        RemoveDrawObject("dummy_dot");
        Generally, the suggestion is to allow the platform to control rendering for performance reasons, in cases where you need to force a refresh it would still be suggested to allow the platform to manage the rate in which that is refreshed (ForceRefresh()). That doesn't always cover all cases and when an immediate reload is needed removing an object will cause the chart to update as this is a platform event.

        Please note that this is not a solution when updates are needed frequently, this would be a good solution for a button press as an example. If you are going to be using this from OnRender or something that is called frequently, this can actually reduce performance and lead to longer refresh times. If your concept requires that this is called frequently, I would revert back to just allowing the chart to control the refresh as there is no safe way to invalidate the panel.


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

        Comment


          #5
          Hello

          Could I "reload NinjaScript" from the code like with F5 key ?

          Thank you

          Comment


            #6
            ninjo,

            There is not a documented way to reload NinjaScript programmatically. You could likely use SendKeys to invoke F5 which would reload NinjaScript, but you should be careful with that method as you could run into further issues where it is called recursively. This is general C# and would be outside any support we could provide.
            Josh G.NinjaTrader Customer Service

            Comment


              #7
              Hello JoshG

              Interesting... I understand I can use carefully.
              Could you help me to find some example that works in NT8?

              Thank you

              Comment


                #8
                ninjo,

                This would not be something we could provide support for. Perhaps another user can provide further information.
                Josh G.NinjaTrader Customer Service

                Comment


                  #9
                  All right JoshG, thank you !
                  Last edited by ninjo; 03-13-2019, 01:38 PM.

                  Comment


                    #10
                    I got it with a simple code but I need to update a "NinjaScriptProperty" value with this chart update.
                    I am setting in the button function with the F5 Sendkey, but doesnt work. The initial value of the "NinjaScriptProperty" occur

                    Its possible to modify a "NinjaScriptProperty" property like with I change in the Indicator window?


                    Thank you for the support JoshG

                    Comment


                      #11
                      ninjo,

                      I am not sure what you are asking here. Are you trying to reload the indicator from the Indicators window?
                      Josh G.NinjaTrader Customer Service

                      Comment


                        #12
                        OK, I got it.
                        Excuse me, I dont know How to remove invalid messages...

                        Thank you

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by DayTradingDEMON, Today, 09:28 AM
                        2 responses
                        15 views
                        0 likes
                        Last Post DayTradingDEMON  
                        Started by Stanfillirenfro, Today, 07:23 AM
                        6 responses
                        23 views
                        0 likes
                        Last Post Stanfillirenfro  
                        Started by navyguy06, Today, 09:28 AM
                        1 response
                        6 views
                        0 likes
                        Last Post NinjaTrader_Gaby  
                        Started by cmtjoancolmenero, Yesterday, 03:58 PM
                        8 responses
                        32 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by helpwanted, Today, 03:06 AM
                        2 responses
                        22 views
                        0 likes
                        Last Post NinjaTrader_LuisH  
                        Working...
                        X