Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Update or redraw vertical line on button click event

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

    Update or redraw vertical line on button click event

    Hi, short question,

    i have a vertical line drawn by a strategy. i did add some toolbar buttons to the chart toolbar to move the vertical line left and right one bar on button click. Problem is, although the code to move or redraw the line is imbedded in the mouseclick event method the line is not moving or redrawn until there is an On Bar Update() event. How to I get the movement or redrawment of the line triggered on button click. do i use a custom event trigger or how is this possible?

    regards

    #2
    Hello,

    You could try utilizing the ForceRefresh method



    This may or may not work for the exact use, please try this first and let me know if the visual is updated after using this method. If it is not, we could look into other items.

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

    Comment


      #3
      Hi Jesse,

      ForceRefresh will not work, I think, due to the code being used in a strategy, I tried this myself, but I get an error message saying that ForceRefresh is not available in the context.

      regards

      Comment


        #4
        Hello,

        Thank you for the reply.

        That is my mistake, I had forgot this was not allowed in strategies.

        Due to the nature of strategies I will need to confirm with development if there is a suggested way to force the refresh of a DrawingObject created from a strategy for this type of use.

        I will reply back once I have further details.

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

        Comment


          #5
          Hello,

          I just wanted to provide a note on this.

          I had some feedback from Product management regarding potentially adding ForceRefresh to other NinjaScript types, at this time this has at least been entered as a feature request and is being reviewed. Unfortunately there is nothing solid on this at the moment on this, but if I have any more information relayed to me I will post it here. For the time being there is unfortunately not a documented workaround regarding causing a Strategy to reload the chart.

          The only solution I can think of for the time being would be to somehow move the logic for the button from the strategy it is currently in to an indicator and have the strategy Add that indicator. You would then have access to the force refresh in the Indicator. This would create problems in the case the logic needs to be in both scripts though as you would need to expose Properties to transmit that data.

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

          Comment


            #6
            Hi Jesse,

            thanks for your feedback, I think ForceRefresh() being available in strategies whould be a great improvement. For now I removed the drawobject before moving it. Removing drawobjects should update chartcontrol. Not what I wanted, but as you said possibilities are limited.

            regards

            Comment


              #7
              You may be able to identify the chart window and do something like...

              chartWindow.ChartControl.ChartPanel.Invalidate();
              chartWindow.ChartControl.ChartPanel.Update();

              That would essentially allow you to escape the strategy, but first you would have to capture the "ChartWindow" object and store it as chartWindow.

              Comment


                #8
                Hello,

                I just wanted to reply back on this item.

                It looks like the feature request has actually gone through and is targeted at B14.

                For the time being I would still suggest to move the code into a indicator at least for testing. I would not suggest using the mentioned ChartControl.ChartPanel.Invalidate as there is no documentation or expectations for this method meaning that errors could arise by its use. This is a internal method used for internal items. There is also a note on the ForceRefresh page regarding the use of Invalidate in the platform:

                It is NOT recommended to invalidate the chart control directly as this could cause issues with threading which result in dead locks.
                I look forward to being of further assistance.
                JesseNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by sidlercom80, 10-28-2023, 08:49 AM
                169 responses
                2,268 views
                0 likes
                Last Post QuantKey_Bruce  
                Started by Irukandji, Yesterday, 02:53 AM
                2 responses
                17 views
                0 likes
                Last Post Irukandji  
                Started by adeelshahzad, Today, 03:54 AM
                0 responses
                3 views
                0 likes
                Last Post adeelshahzad  
                Started by CortexZenUSA, Today, 12:53 AM
                0 responses
                3 views
                0 likes
                Last Post CortexZenUSA  
                Started by CortexZenUSA, Today, 12:46 AM
                0 responses
                1 view
                0 likes
                Last Post CortexZenUSA  
                Working...
                X