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

How to hide / unhide a plot?

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

    How to hide / unhide a plot?

    I have a button on the toolbar that I want to use to toggle a plot to visibile/show to invisible/hidden;....

    I can do this in NT7 but NT8 seems to store the latest Brush in the Chart Parameters...NT7 didn't do this?

    I can set the plot brush to Transparent dynamically (hidden), but then how do I get it to Show again?

    (for the entire chart, the plots also on the historical data)

    I'm stumped...

    Thanks

    #2
    Hello llanqui,

    You can use a Brush variable and set the variable to the Plot[0].Brush value in State.DataLoaded to store it.

    Then you can set the Plot[0].Brush to Brushes.Transparent or to the variable.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Well, but it seems that Ninja is changing the plot brushes in the Chart Parameters...that means it gets stuck in Brushes.Transparent...

      that way when the indicator loads again the parameter values have been reset...and the brush color is no longer what I originally set...it is getting lost....it is now Transparent

      or, am I missing something

      Comment


        #4
        Hello llanqui,

        You could set the brush back to the original brush in State.Terminated.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          that would be the brush I found in State.DataLoaded?

          Comment


            #6
            Hello llanqui,

            The variable would be assigned the Plot.Brush in State.DataLoaded. The Plot.Brush would be assigned back the value of the variable in State.Terminated to set it back.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              "You could set the brush back to the original brush in State.Terminated."

              that doesn't seem to be working

              Comment


                #8
                else if (State == State.Terminated)
                {

                // reset Parameters Bruses back to (my) default
                Plots[0].Brush = Brushes.ForestGreen;
                Plots[1].Brush = Brushes.Red;​

                }


                Ninja is still resetting the Brush on both to Transparent

                Comment


                  #9
                  I should probably make a new posting for this??

                  (it affects my testing in NT8 also)

                  In NT7 I was very confused about when an indicator was integrated into the run time after compile

                  sometimes I had to exit Ninja and start again, because reloading the indicator (on the chart) did not bring in the new compile) did not bring in the new version

                  sometimes I even had to reboot the machine....to get the new version of the indicatior..

                  In NT8 it seems there is some hangover from this....much of the time if I compile the indicator is correct when I reload it...however I've noticed sometimes it acts lilke NT7.

                  I don't know what is going on here.....is there a thread for this

                  Comment


                    #10
                    I know I have a few posts here in a row....but .... is there a property I can set on the plot to hide it? And to reshow it?

                    that would be so much easier !!

                    in NT7 I had to change the Bar Color...

                    Comment


                      #11
                      Ok, I have it working now.

                      Comment


                        #12
                        Hello llanqui,

                        Apologies for the delay, I did need to research this further.

                        Indicators are cloned while the State is State.Realtime, which mean setting the plot in State.Terminated is too late.

                        A workaround instead, is to override the Clone() method, and set the plot value on the new clone.
                        https://ninjatrader.com/support/help.../nt8/clone.htm

                        Attached is an example.
                        CloneOverridePlotBrushVisibilityToggleExample_NT8. zip

                        (Update Feb 24th, after recompiling NinjaScript, the NinjaScript instance in the Chart would not be the same type as any new instances of the same NinjaScript, and when it uses the ‘as’ operator it’s still trying to use the old type.. The solution to this is to cast to a base class that would not be part of the recompile (such as NinjaScriptBase) and update what properties are possible there. In cases of properties that are specific to the NS file in question, you would need to employ TypeInfo to get/set property values for the new instance.)
                        Attached Files
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Hi Chelsea,

                          Thank you for your example but after compilation the indicator throws error.

                          Comment


                            #14
                            Hello frslvr,

                            I'm not able to reproduce.

                            Below is a link to a video showing this script imports without issue, and can be applied to a chart without error.


                            You may have compile errors from something else.
                            Below is a link with instructions on how to compile and look for errors.
                            Hi all, My NT8 software Strategy Builder has stopped functioning AND Script Editor isn't working for my strategy either. SB tells me to use SE and SE tells me to use SB for my Strategy. I have tried to restart PC and Software. No luck. Looks like my strategy file has been corrupted :( How do I get my SB to function again so I
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #15
                              Chelsea,

                              Please try to open the editor and click Compile, then try to change the indicator's parameters.
                              Please watch the video: https://youtu.be/zLFg-gy2JJU

                              The error was probably caused by something else in my case only. But that something else caused by this issue.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Waxavi, Today, 02:10 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post Waxavi
                              by Waxavi
                               
                              Started by TradeForge, Today, 02:09 AM
                              0 responses
                              8 views
                              0 likes
                              Last Post TradeForge  
                              Started by Waxavi, Today, 02:00 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post Waxavi
                              by Waxavi
                               
                              Started by elirion, Today, 01:36 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post elirion
                              by elirion
                               
                              Started by gentlebenthebear, Today, 01:30 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post gentlebenthebear  
                              Working...
                              X