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

plot chart option to reflect to certain plots of indicator only

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

    plot chart option to reflect to certain plots of indicator only

    Hello all,

    in strategy builder when I add an indicator into a condition I have the option to choose "Plot chart". By this way the used indicator is plotted whenever the strategy is enabled without the need to have that particular indicator loaded in "indicator window". However, this will plot ALL existing plots of that indicator Is there a way to tell the strategy to plot only indicator 1,3 and 6 ? Or whatever combination I like to?

    looking forward to your reply. Thank you.

    #2
    Hello patricia70,

    You can set the colors of the plots you do not want to see to Transparent.

    Or you can copy the indicator and modify the logic to include bool inputs to turn on and off the conditions that set the plot values.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello ChelseaB,

      my indicator already have set the plot I do not want to see to "Transparent". I try to explain...

      In the beginning I set a bool for that desired plot and its color and a series that I need for the values:
      Code:
      private bool showREOP = true;
      private System.Windows.Media.Brush REOPBrush = Brushes.Blue;
      private Series<double> REOP;
      Then in the OnStateChange() method...

      Inside the (if State.SetDefaults) block I create the initial plot:
      Code:
      AddPlot(new Stroke(Brushes.Gray, 2), PlotStyle.Line, "Foo");
      Inside the (else if State.Configure) block I use:
      Code:
      Plots[0].Brush = REOPBrush.Clone();
      Plots[0].Width = plot0Width;
      Plots[0].PlotStyle = plot0Style;
      Plots[0].DashStyleHelper = dash0Style;
      Inside the (else if State.DataLoaded) block I use:
      Code:
      REOP = new Series<double>(this, MaximumBarsLookBack.TwoHundredFiftySix);
      In the indicator menu I can leave the checkbox empty for that particular plot (boolean), the plot in this case is set to transparent:
      Code:
      if(!showREOP)
      PlotBrushes[0][0] = Brushes.Transparent;
      The properties region looks like that:
      Code:
      #region Properties
      [Browsable(false)]
      [XmlIgnore()]
      public Series<double> REOP
      {
      get { return Values[0]; }
      }
      
      [Display(ResourceType = typeof(Custom.Resource), Name = "Show REOP", Description = "Shows the REOP foo bar", GroupName = "Display Options", Order = 0)]
      [RefreshProperties(RefreshProperties.All)]
      public bool ShowREOP
      {
      get { return showREOP; }
      set { showREOP = value; }
      }
      
      [XmlIgnore]
      [Display(ResourceType = typeof(Custom.Resource), Name = "reop", Description = "Sets the color for the reop", GroupName = "Plot Colors", Order = 0)]
      public System.Windows.Media.Brush REOPBrush
      {
      get {return REOPBrush;}
      set {REOPBrush = value;}
      }
      
      [Browsable(false)]
      public string REOPBrushSerializable
      {
      get { return Serialize.BrushToString(REOPBrush); }
      set { REOPBrush = Serialize.StringToBrush(value); }
      }
      Code:
      [...]
      namespace NinjaTrader.NinjaScript.Indicators.myIndicators
      {
      public class myIndiTypeConverter : NinjaTrader.NinjaScript.IndicatorBaseConverter
      {
      public override bool GetPropertiesSupported(ITypeDescriptorContext context) { return true; }
      
      public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes)
      {
      PropertyDescriptorCollection propertyDescriptorCollection = base.GetPropertiesSupported(context) ? base.GetProperties(context, value, attributes) : TypeDescriptor.GetProperties(value, attributes);
      
      myIndi thisOPRAInstance = (myIndi) value;
      myIndiPRSETypeOR PRSETypeFromInstance = thisOPRAInstance.PRSEType;
      bool showREOPFromInstance = thisOPRAInstance.ShowREOP;
      
      PropertyDescriptorCollection adjusted = new PropertyDescriptorCollection(null);
      
      foreach (PropertyDescriptor thisDescriptor in propertyDescriptorCollection)
      {
      if(!showREOPFromInstance && (thisDescriptor.Name == "REOPBrush"|| thisDescriptor.Name == "Plot0Style" || thisDescriptor.Name == "Dash0Style" || thisDescriptor.Name == "Plot0Width" ))
      adjusted.Add(new PropertyDescriptorExtended(thisDescriptor, o => value, null, new Attribute[] {new BrowsableAttribute(false), }));
      Unfortunately the plot appears when I try to attach a limit (stop-loss or take-profit) to that indicator. According to this example I have over 14 plots in that indicator, but I only want the plots to appear in the "attach to limit" list or in "strategies" whenever the bool checkbox is in use. What am I doing wrong, how can I fix this? any further help appreciated.

      thanks in advance and kind regards

      Comment


        #4
        Hello patricia70,

        Thank you for providing further specifics.

        If you remove the 'if(!showREOP)' condition and always set PlotBrushes[0][0] to Brushes.Transparent does the behavior still occur?

        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello Chelsea. Yes, even when I permanently set to transparent brushes the plot is visible in limit orders (Attach to indicator).

          Comment


            #6
            Hello patricia10,

            Thanks for the reply.

            So we understand correctly, are you stating the plot lines appear after using Attach To Indicator, despite using PlotBrushes[X][0] = Brushes.Transparent; to made the plot line invisible? When I test this, I do not get a plot line displayed, and Attach To Indicator does not make the plot line appear, which I would expect.

            Or do you mean you are trying to prevent some of the plots from listing in the Attach To Indicator menu? If this is your intention, I would then suggest to create a shell indicator that just adds plots for what you want to have displayed. That indicator can then add your base indicator and only assign plot values for the plots you want to have listed.

            If this does not resolve your inquiry, could you attach screenshots that further describe your intentions?

            To send a screenshot with Windows 7 or newer I would recommend using the Windows Snipping Tool.

            Click here for instructions

            Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file and send the file as an attachment.

            Click here for detailed instruction

            We look forward to assisting.
            JimNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Jim View Post
              Or do you mean you are trying to prevent some of the plots from listing in the Attach To Indicator menu? If this is your intention, I would then suggest to create a shell indicator that just adds plots for what you want to have displayed. That indicator can then add your base indicator and only assign plot values for the plots you want to have listed.
              Yes Jim, that's exactly what I'm aiming for. I do not want the plot to be listed neither in the "Attach to indicator" menu nor in a strategy builder condition setup. This is actual the case. What is a shell indicator, can you provide some more information so I could try to reach this goal?

              My real problem is this: I have an indicator "myIndi". I create a new strategy with the Strategy Builder. There I have a condition "If Close greater than indicator "myIndi" plot 1 then ..." I check the box "Plot on Chart" for my desired plot 1 but this causes ALL existing plots (over 20 !) from this indicator to be drawn by the strategy. This is very confusing! My indicator "MyIndi" by default plots only Plot1 which I have enabled through a bool variable. Nevertheless, all 20 plots are drawn by the strategy and this although I have explicitly selected my desired plot in the condition of the strategy builder as condition / criterion.

              How do I fix this? thank you for your patience and assistance.
              Last edited by patricia70; 07-05-2021, 07:53 AM.

              Comment


                #8
                Hello patricia70,

                What I mean by "shell indicator" is that you can make an indicator that adds your own indicator within it, and that "shell indicator" can add 3 plots. Just the number of plot you want to use for the strategy and for the Attach To Indicator capability. Then you can assign the plots in the "shell indicator" with the specific plot values from your main indicator.

                I have attached a screenshot showing how you can create a "shell indicator" that adds one plot and displays the default MACD plot only.

                Let us know if you have any additional questions.
                Attached Files
                JimNinjaTrader Customer Service

                Comment


                  #9
                  and how do I pass all the settings that I normally enter in the settings menu of the indicator? I have around 10 settings, they are boolean variables, numeric, time of day, etc.

                  Comment


                    #10
                    Hello patricia70,

                    You would add user inputs to the "shell indicator" as would be done with any indicator to be able to set its parameters. (The same is done when you add user inputs to a strategy to control the parameters of an indicator added in it.) The parameters would then be used with the constructor of the indicator within your "shell indicator."

                    For example, with post #8, you can add user inputs for the 3 MACD parameters, and use the 3 user input variables for the constructor of the MACD in State.DataLoaded.



                    You can also consider using the Strategy Builder to create syntax for adding the indicator with user input parameters. After the parameters are added in the "shell indicator" to control how the indicator inside is created, you would add inputs to the strategy to control how the "shell indicator" gets created.

                    The result ends up being the same indicator that you have been using, but only the plots you want to expose will be seen.
                    JimNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by trilliantrader, 04-18-2024, 08:16 AM
                    4 responses
                    18 views
                    0 likes
                    Last Post trilliantrader  
                    Started by mgco4you, Today, 09:46 PM
                    1 response
                    7 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by wzgy0920, Today, 09:53 PM
                    0 responses
                    9 views
                    0 likes
                    Last Post wzgy0920  
                    Started by Rapine Heihei, Today, 08:19 PM
                    1 response
                    10 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by Rapine Heihei, Today, 08:25 PM
                    0 responses
                    10 views
                    0 likes
                    Last Post Rapine Heihei  
                    Working...
                    X