• 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

How to hide plots from indicator ?

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

    How to hide plots from indicator ?

    Hi,

    I'm using an indicator in my strategy. I would like to hide some of the plots that are available in the settings for that indicator. How can I achieve this in code?


    As an example:

    If you look at the Moving Average Ribbon, it has about 8 moving avg. plots . I want to hide 4 of them or make the brushes transparent, how can I do this in the code?

    do you have a sample that I can emulate?

    Thank you in advance.


    #2
    Hello priceisking,

    Thank you for your post.

    This would be a matter of setting the undesired plots to have transparent brushes.

    So, for example, if I wanted to hide the 2nd, 4th, 6th and 8th plot of that particular indicator, it would look like this:

    Code:
            private MovingAverageRibbon MAR1; // create variable for our MA ribbon
    
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                = NinjaTrader.Custom.Resource.NinjaScriptStrategyDescriptionSampleMACrossOver;
                    Name                    = "HidePlotsMARibbonTest";
                    BasePeriod                = 10;
                    IncrementalPeriod        = 10;
                    // This strategy has been designed to take advantage of performance gains in Strategy Analyzer optimizations
                    // See the Help Guide for additional information
                    IsInstantiatedOnEachOptimizationIteration = false;
                }
                else if (State == State.DataLoaded)
                {
    
                    MAR1 = MovingAverageRibbon(RibbonMAType.Exponential, BasePeriod, IncrementalPeriod); //create our instance of the ribbon by assigning it to our variable
    
                    MAR1.Plots[1].Brush = Brushes.Transparent;  //set desired plot brushes to transparent
                    MAR1.Plots[3].Brush = Brushes.Transparent;
                    MAR1.Plots[5].Brush = Brushes.Transparent;
                    MAR1.Plots[7].Brush = Brushes.Transparent;
    
                    AddChartIndicator(MAR1); //add indicator to chart with modified brushes for the desired plots
                }
            }
    Here is a link to our help guide on the MA Ribbon:

    https://ninjatrader.com/support/help...gaverageribbon

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Thank you. This worked perfectly! Appreciate the quick reply.

      Comment


        #4
        Quick question regarding the plots. Is there a property setting for the plot if I want to displace it further by say 10?

        Can I do something like :
        MAR1.Plots[3].Displacement = 20; ? I tried it but doesn't work.

        Comment


          #5
          Hello priceisking,

          Thank you for your reply.

          There's not really a displacement property within a strategy that you can just adjust the plot in that way. However, you could manually plot a displaced version of your indicator by getting the information from the desired Bars ago and plotting that directly from the strategy instead of plotting the current values from the indicator.

          Here's a link to our help guide that goes over plotting directly from a strategy:

          https://ninjatrader.com/support/help..._a_ninjasc.htm

          You could also create a modified version of the MA Ribbon that would give your strategy the displaced data from X number of bars ago, and then include it in the strategy.

          Lastly, you could simply not plot the indicator in your strategy, and instead use a version of the indicator on the chart along with the strategy that has the displacement set. To reference those values in your strategy, you could just do something like MAR1[20].MovingAverage1 to get the MAR1 value of the MovingAverage1 plot from 20 bars ago, for example.

          Please let us know if we may be of further assistance to you.

          Kate W.NinjaTrader Customer Service

          Comment


            #6
            Thank you . .. Will take that approach and revert back if any issues.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by RobertoPaez, Today, 06:47 PM
            0 responses
            4 views
            0 likes
            Last Post RobertoPaez  
            Started by catinabag, Today, 06:45 PM
            0 responses
            3 views
            0 likes
            Last Post catinabag  
            Started by darkgreen, Today, 03:35 PM
            0 responses
            7 views
            0 likes
            Last Post darkgreen  
            Started by GTBrooks, Today, 02:44 PM
            3 responses
            14 views
            0 likes
            Last Post GTBrooks  
            Started by GLFX005, Today, 12:22 PM
            4 responses
            41 views
            0 likes
            Last Post NinjaTrader_Kate  
            Working...
            X