Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ForceRefresh, Update, candlestick selected...

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

    ForceRefresh, Update, candlestick selected...

    Hello,

    I am creating a new indicator; most is going well except for two issues.

    The indicator will be used while the market is opened and for review after the market is closed.

    The user clicks on areas of the chart while pressing a configurable key and the indicator draws objects on the chart via flags set in the mouse click handler and drawn in the next OnBarUpdate.

    #1

    When the market is closed, I cannot get the OnBarUpdate to fire after the initial loading of the data. ForceRefresh and Update calls do not force a OnBarUpdate call.

    #2

    When the user clicks on a candlestick (which is OK) and is pressing a valid key the candlestick series (all the candlestick) is selected. I tried setting e.handled to true in the mouse click event handler, no joy.

    I am not sure which is called first, my indicator mouse click handler or the logic to select the candlesticks.

    Ideas?

    Thanks,

    Mark



    #2
    Use a timer to trigger a custom event at an interval - try following this example: https://ninjatrader.com/support/help...ustomevent.htm
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Originally posted by QuantKey_Bruce View Post
      Use a timer to trigger a custom event at an interval - try following this example: https://ninjatrader.com/support/help...ustomevent.htm
      Thanks for the response.

      I tried wrapping the ForceRefesh and Update in a TiggerCustomEvent in the MouseClick handler with no joy. Perhaps I will try a timer.

      Comment


        #4
        Remember, you don't want to "force an OnBarUpdate call" - you want to redraw the screen when your special situation happens. Maybe NinjaTrader support can comment on if there is any reason that a timer -> TriggerCustomEvent() -> do some things -> ForceRefresh() might be insufficient to get the screen to redraw with the changes during closed market hours. NinjaTrader_ChelseaB will likely know what is possible here.
        Bruce DeVault
        QuantKey Trading Vendor Services
        NinjaTrader Ecosystem Vendor - QuantKey

        Comment


          #5
          Thanks for the response.

          Are you asserting adding/modifying drawing objects outside of OnBarUpdate will be reflected in the window without OnBarUpdate being called?

          Comment


            #6
            Yes, they would be if you ForceRefresh, and possibly even if you do not because they would be automatically invalidated.
            Bruce DeVault
            QuantKey Trading Vendor Services
            NinjaTrader Ecosystem Vendor - QuantKey

            Comment


              #7
              Thanks for the help Bruce.

              After a time, trying different solutions, I was able to modify and move the objects without OnBarUpdate
              ForceRefersh was required. OnBarUpdate was not called.

              Now to issue two of the initial message post.
              .

              Comment


                #8
                It sounds like you want to make it so the user is unable to select the chart series with their mouse. If you were able to successfully do that, how would they then select the series to move it up or down in the ZOrder or otherwise manipulate the data series? That's a functionality people expect in NinjaTrader...
                Bruce DeVault
                QuantKey Trading Vendor Services
                NinjaTrader Ecosystem Vendor - QuantKey

                Comment


                  #9
                  One approach you could use would be to use plots to draw on top of the candlesticks so that when they try to click on the candles, it's always clicking on your indicator because the indicator is on top, but that seems kind of clumsy. (You could make the actual plots not show up by overriding OnRender or making them transparent etc.) Maybe someone else has an idea on this.
                  Bruce DeVault
                  QuantKey Trading Vendor Services
                  NinjaTrader Ecosystem Vendor - QuantKey

                  Comment


                    #10
                    Originally posted by QuantKey_Bruce View Post
                    It sounds like you want to make it so the user is unable to select the chart series with their mouse.
                    If one of the indicator configured keys is not down (pressed) I ignore mouse clicks and do nothing.

                    Comment


                      #11
                      Originally posted by Mark-- View Post
                      If one of the indicator configured keys is not down (pressed) I ignore mouse clicks and do nothing.
                      Found a solution.

                      Code:
                      if (ChartBars.IsSelected)
                       ChartBars.IsSelected = false;​

                      Comment


                        #12
                        Great. Sounds like it will all work out.
                        Bruce DeVault
                        QuantKey Trading Vendor Services
                        NinjaTrader Ecosystem Vendor - QuantKey

                        Comment


                          #13
                          Hello Mark~~,

                          Thanks for your post.

                          I am happy to hear you found a solution. The ChartBars class provides GUI access related methods and properties to the primary bars series configured on the Chart through the Data Series menu.

                          Note that ChartBars.IsSelected is not a documented property and it would be up to your discretion to use this in a script.

                          ChartBars: https://ninjatrader.com/support/help.../chartbars.htm
                          Last edited by NinjaTrader_BrandonH; 05-07-2023, 05:57 PM.
                          <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                          Comment


                            #14
                            Originally posted by NinjaTrader_BrandonH View Post
                            Note that ChartBars.IsSelected is not a documented/supported property and it would be up to your discretion to use this in a script
                            OK, do you have another solution?

                            Comment


                              #15
                              Hello Mark~~,

                              Thanks for your note.

                              There is an option available for allowing the chart bars to be selected or not in the chart's properties menu.

                              You could use ChartControl.Properties.AllowSelectionDragging = false; to prevent the chart bars from being selectable.

                              Please let me know if I may assist further.
                              <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              650 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              370 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              109 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              574 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              577 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X