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

Forcing recalculation/redraw of an Indicator without context loss

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

    Forcing recalculation/redraw of an Indicator without context loss

    I have an indicator that plots volume histograms for individual sessions similar to the dValueArea Indicator.

    However, my indicator additionally allows sub session volume histograms to be triggered and displayed within a session. I accomplish this by modifying variables in the indicator's properties window. I use a boolean flag to specify a secondary session and a DateTime variable to indicate the time (bar) at which to start drawing the sub session histogram.

    All of this works fine when using the indicator's property panel and applying the changes manually. The values specified in the properties indicator appear to take
    precedence over the defaults specified in the indicators #variables region as they should do.

    My problem is that I have added a simple toolstrip button to do the same thing. The button sets the boolean flag and captures the desired bar to set the timestamp.

    My problem is that, unlike applying changes from the indicator's properties panel which apparently re-initializes and redraws the chart using the values from the indicator's property window, I get no changes when using the toolstrip button.

    I have tried calling ChartControl.ChartPanel.Invalidate() and ChartControl.Refresh() from OnMarketUptate() and within the button click routine to no avail to refresh the chart.

    I have tried manually reloading (F5) the indicator also, but the state captured by the toolstrip button seems to be lost after the operation.

    I would greatly appreciate any advice that sheds light on the sequence of events that are triggered when an indicator's properties are manually changed and how to initiate those changes programmatically in a manner that is consistent with the simple update of an indicator.

    Thanks in advance and I apologize if I am posting a redundant thread. I have not found the answer yet.

    #2
    Hello Wolf50us,

    Thank you for your note.

    The manual reload of the chart I would expect to work however, the fields that you have in the tool strip, how are they passing the values to the indicator to update?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      They are stored in the same global class variables that the fields defined in the indicator's property
      panel manage. This is why I suspect they are being reset to their default state with the F5 reload.

      My problem is that I am constructing several internal arrays that capture current session state and are built as each bar is processed when OnUpdate() is called. These internal arrays need to be reconfigured from scratch to properly recalculate the new subsession histograms.

      This recalculation apparently happens when the indicator's property panel fields are modified and the modified variables take precedence over the initial settings defined when the indicator is first loaded.

      I would like to similarly override the indicators initial state data with new state data taken from the toolstrip as opposed to new state data taken from the property panel.

      Thanks in advance!

      Comment


        #4
        Wolf50us,

        Please keep in mind that this is not supported programming with NinjaTrader, but I would like to test your script on my end and see what is occurring. Can you send me your script to test?

        platformsupport [at] ninjatrader [com] Attn Cal in the subject and reference this thread
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Cal,

          Thanks for your quick response. You guys are very helpful!

          Your question at to which variable I was setting triggered my thoughts along a new line.

          After experimentation I realized NinjaTrader was serializing variables in the #properties region and
          that by placing variables there I could have them serialized over F5 reloads.

          In my previous code I had removed the variables from the #properties region as I figured that I would
          no longer be setting them by hand. This is where I ran into problems.

          This completely solved the problems I was having and I am sure this technique can be helpful in
          other ways in the future.

          Once again, thank you for your help!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by mjairg, 07-20-2023, 11:57 PM
          3 responses
          213 views
          1 like
          Last Post PaulMohn  
          Started by TheWhiteDragon, 01-21-2019, 12:44 PM
          4 responses
          544 views
          0 likes
          Last Post PaulMohn  
          Started by GLFX005, Today, 03:23 AM
          0 responses
          3 views
          0 likes
          Last Post GLFX005
          by GLFX005
           
          Started by XXtrader, Yesterday, 11:30 PM
          2 responses
          12 views
          0 likes
          Last Post XXtrader  
          Started by Waxavi, Today, 02:10 AM
          0 responses
          7 views
          0 likes
          Last Post Waxavi
          by Waxavi
           
          Working...
          X