• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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

    http://ninjatrader.com/support/helpG...b=ForceRefresh

    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 Simon Investimens, Today, 03:26 AM
                0 responses
                3 views
                0 likes
                Last Post Simon Investimens  
                Started by EnveousColnago, Yesterday, 06:58 AM
                1 response
                13 views
                0 likes
                Last Post NinjaTrader_ChrisSch  
                Started by owreivmatot, Today, 01:38 AM
                0 responses
                1 view
                0 likes
                Last Post owreivmatot  
                Started by lindsayf, Today, 01:13 AM
                0 responses
                6 views
                0 likes
                Last Post lindsayf  
                Started by thgamey, Yesterday, 06:46 PM
                1 response
                10 views
                0 likes
                Last Post NinjaTrader_ChrisSch  
                Working...
                X