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

Help with code (Zone Shading)

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

    Help with code (Zone Shading)

    Hello,

    I hacked together this indicator (not knowing what I am doing). I almost have it plotting the way I want it but I am missing one part that I can't figure out. I am trying to get it to shade both zones ( 2-3 std above and below an ema). See attached. I can only get the top zone shaded. Can anyone shed some light on how to shade the bottom zone?

    Thanks for the help,

    Tommy
    Attached Files

    #2
    Please disregard the Plot override method. Use DrawRegion() method available in NinjaTrader 6.5.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the reply. Do you know if there is any example code of how it would be done? I don't know much about programming, I just pasted a bunch of code together and kept tweaking it until it compiled and displayed correctly .

      Thanks

      Comment


        #4
        Please see the Reference Samples section in the forums: http://www.ninjatrader-support.com/v...ead.php?t=4331
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Thanks for the info. I have it working with "DrawRegion"

          In the example script the color settings and opacity settings are hard coded. Is it possible to make them user definable?

          Comment


            #6
            You can do that just like how you would do any other variable. Please see other indicators like the SMA on how to get user definable variables.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              I have another question. I have the indicator working except every time I close and reopen NT the DrawRegion color defaults back to the default even though I changed it on the chart. I guess I missed something but i'm not sure what. Any ideas?


              #region Variables
              private int period = 34;
              private Color FillColor = Color.Blue;
              private Color XMAColor = Color.Transparent;
              #endregion



              DrawRegion("XMA Zone", CurrentBar, 0, EMA( High, Period ), EMA( Low, Period ), XMAColor, FillColor, 2);



              Thanks

              Comment


                #8
                Drawing to the Right of last price bar

                Is it possible to set 'Right side margin' to a high number (e.g., 40) and draw items in the space between the last price bar and the right side of the chart (e.g., DrawRectangle)?

                Comment


                  #9
                  tommyjames: The colors will be the defaults every time you use the indicator again. If you want different default colors, change it in the Variable section.

                  spenbm01: You currently cannot programmatically draw in the right hand region, but you can do it manually through the chart draw tools.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Yes I understand that they will be defaults when I add the indicator to a chart but the colors default back on an existing chart with the indicator already on it. It is the only indicator that does this, so there must be something missing in the code.

                    Thanks

                    Comment


                      #11
                      I didn't notice anything off the bat. If you could post the indicator I can take a quick look for you to see if there truly isn't anything out of place.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Here is the indicator....
                        Attached Files

                        Comment


                          #13
                          tommyjames,

                          Try serializing your color parameter.

                          After your XMA Color in the "Properties" section add this
                          Code:
                          [Browsable(false)]
                          public string XMAColorSerialize
                          {
                              get { return NinjaTrader.Gui.Design.SerializableColor.ToString(XMAColor); }
                              set { XMAColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
                          }
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            Thanks for the reply. I put the code in but it still behaves the same.....

                            Is this a new section or is it in place of the existing section?

                            Any more ideas?

                            Thanks
                            Last edited by tommyjames; 04-07-2008, 11:17 AM.

                            Comment


                              #15
                              Try adding one for the FillColor also.

                              These should be new sections in the Properties region of your code.

                              That region should look like this:
                              Code:
                                      /// <summary>
                                      /// </summary>
                                      [XmlIgnore()]
                                      [Description("Zone Color")]
                                      [Category("Colors")]
                                      [Gui.Design.DisplayNameAttribute("Zone Color")]
                                      public Color fillColor
                                      {
                                          get { return FillColor; }
                                          set { FillColor = value; }
                                      }
                                      
                                      [Browsable(false)]
                                      public string FillColorSerialize
                                      {
                                          get { return NinjaTrader.Gui.Design.SerializableColor.ToString(FillColor); }
                                          set { FillColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
                                      }
                                      
                                      /// <summary>
                                      /// </summary>
                                      [XmlIgnore()]
                                      [Description("XMA Color")]
                                      [Category("Colors")]
                                      [Gui.Design.DisplayNameAttribute("XMA Color")]
                                      public Color xMAColor
                                      {
                                          get { return XMAColor; }
                                          set { XMAColor = value; }
                                      }
                                      
                                      [Browsable(false)]
                                      public string XMAColorSerialize
                                      {
                                          get { return NinjaTrader.Gui.Design.SerializableColor.ToString(XMAColor); }
                                          set { XMAColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
                                      }
                                      
                                      /// <summary>
                                      /// </summary>
                                      [Description("Numbers of bars used for calculations")]
                                      [Category("Parameters")]
                                      public int Period
                                      {
                                          get { return period; }
                                          set { period = Math.Max(1, value); }
                                      }
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Aviram Y, Today, 05:29 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post Aviram Y  
                              Started by quantismo, 04-17-2024, 05:13 PM
                              3 responses
                              25 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by ScottWalsh, 04-16-2024, 04:29 PM
                              7 responses
                              34 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by cls71, Today, 04:45 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post cls71
                              by cls71
                               
                              Started by mjairg, 07-20-2023, 11:57 PM
                              3 responses
                              217 views
                              1 like
                              Last Post PaulMohn  
                              Working...
                              X