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

Indicator calculations stop when chart lost focus

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

    Indicator calculations stop when chart lost focus

    Hello!

    Some Indicator calculations stop when chart lost focus although I wrote:

    Code:
    IsSuspendedWhileInactive = false;
    (The Print function works when chart lost focus but not the "UP" key code)

    Please, test the attachment. Install in a chart, update, and change to other window, for example Output Window. Yo can see the Print string updating, but not the UP key trigger


    Thank you.

    Attached Files

    #2
    Hello ninjo,
    Thanks for your post.

    This is because SendKeys is not targeting anything specific and it must for it to work the way you are expecting. It's also not meant for WPF as it is part of WinForms so it will not work the way you expect it to in this context. In general it would likely be a better solution in NinjaTrader to use RaiseEvent() and target specific buttons in the window.

    Here are a couple of indicators that use RaiseEvent to achieve something similar:

    Shows a button on the chart to roll the expiry to the next available contract month. Option to hide button until a number of days before or on roll date. Another option to confirm by opening the instrument overlay selector or automatically rollover without confirmation. (Update June 27th, 2019 – Added an option to show […]



    What exactly is your end goal?
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Hello JoshG, thak you for your support.

      My goal is the use of System.Windows.Forms.SendKeys.SendWait("{F5}") for update the chart eventually if my code needs it to update data. I can not be looking at the same graph on my screen for hours :/

      Some idea of how could I code it simple ? Now its so easy with SendKeys function.

      Thank you


      Comment


        #4
        ninjo,

        I am not sure how you would go about doing this. SendKeys will not be the answer. Why do you need to refresh your chart in the first place?
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          Hi JoshG.
          Simple. Sometimes my internet connection fails. During that time the graph does not receive data. When the connection returns, the bars are drawn with a lag and my indicator acts taking into account that lag.
          When it happens, doing a refresh of the chart is the perfect solution. But unfortunately this does not work if the chart does not have the focus.

          Thank you!

          Comment


            #6
            ninjo,

            You can use ReloadAllHistoricalData() to accomplish your goal instead. Please see the following link for more information: https://ninjatrader.com/support/help...oricaldata.htm

            If you are receiving disconnects that frequently I suggest addressing that issue sooner than later.
            Josh G.NinjaTrader Customer Service

            Comment


              #7
              Fantastic JoshG !

              Thank you

              Comment


                #8
                Hello again JoshG,

                I have some buttons (WPF) in my chart.
                When I call the ReloadAllHistoricalData() function happend a blink effect in the WPF controls.

                I disabled the unload of it in the State.Terminated function, but the flicker still.

                How could I keep the button visible when I call the ReloadAllHistoricalData() function so that blinking (the unload of controls) does not occur?

                Thank you
                Last edited by ninjo; 04-08-2019, 02:51 PM.

                Comment


                  #9
                  Hello ninjo,

                  When calling ReloadAllHistoricalData() (or right-clicking the chart and selecting Reload All Historical Data), this will reload all historical data and then must reload all indicators and strategies as well to calculate the new historical data. This means any wpf controls must be removed and re-added as the instance of the script is disabled and re-enabled.
                  I am not aware of any means to prevent this, and if this was prevented would likely cause duplicate controls to appear in the chart after the script is re-enabled.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    OK, I understand.


                    Thank you
                    Last edited by ninjo; 04-09-2019, 02:07 AM.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by bortz, 11-06-2023, 08:04 AM
                    47 responses
                    1,602 views
                    0 likes
                    Last Post aligator  
                    Started by jaybedreamin, Today, 05:56 PM
                    0 responses
                    8 views
                    0 likes
                    Last Post jaybedreamin  
                    Started by DJ888, 04-16-2024, 06:09 PM
                    6 responses
                    18 views
                    0 likes
                    Last Post DJ888
                    by DJ888
                     
                    Started by Jon17, Today, 04:33 PM
                    0 responses
                    4 views
                    0 likes
                    Last Post Jon17
                    by Jon17
                     
                    Started by Javierw.ok, Today, 04:12 PM
                    0 responses
                    12 views
                    0 likes
                    Last Post Javierw.ok  
                    Working...
                    X