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 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:



    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:



          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 bmartz, 03-12-2024, 06:12 AM
            4 responses
            31 views
            0 likes
            Last Post bmartz
            by bmartz
             
            Started by Aviram Y, Today, 05:29 AM
            4 responses
            12 views
            0 likes
            Last Post Aviram Y  
            Started by algospoke, 04-17-2024, 06:40 PM
            3 responses
            28 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by gentlebenthebear, Today, 01:30 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by cls71, Today, 04:45 AM
            1 response
            7 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X