Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Basic coding script questions

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

    #31
    Thanks.

    I now tried BackColor as in

    DrawBackColor(CurrentBar.ToString(),0,Color.Pal eGreen,DashStyle.Solid,3);

    but that does not work either.

    Should it not, when

    DrawVerticalLine(CurrentBar.ToString(),0,Color.Pal eGreen,DashStyle.Solid,3);

    works just fine?

    sandman

    Comment


      #32
      Originally posted by sandman View Post
      Thanks.

      I now tried BackColor as in

      DrawBackColor(CurrentBar.ToString(),0,Color.Pal eGreen,DashStyle.Solid,3);

      but that does not work either.

      Should it not, when

      DrawVerticalLine(CurrentBar.ToString(),0,Color.Pal eGreen,DashStyle.Solid,3);

      works just fine?

      sandman
      DrawBackColor is not a function either. I said BackColor, not DrawBackColor. Coding needs precision.

      Look into the NT help for the correct function that I have identified, please.

      Comment


        #33
        I now have a LinReg indicator which changes color depending on whether it is rising or falling. What I would like to fix in the code is the way it draws when it changes from rising to falling (and vice versa).

        See attached image. It starts off as a rising LinReg so draws the line in green. As I have it set to onBarClose=false it may change during those 5minutes from rising to falling. It currently however keeps showing the green line and just adds a second red line to show falling.

        How do I have to address this in the code so that it only shows one i.e. the actual colored line (even though it may change several times during these 5 minutes).

        sandman
        Attached Files

        Comment


          #34
          sandman, from the screenshot looks like the code is using a legacy method to do the coloring, I would suggest update it to reflect the availability of NT7's PlotColors - http://www.ninjatrader.com/support/h...sub=Plotcolors

          Comment


            #35
            NT7's PlotColors - http://www.ninjatrader.com/support/h...sub=Plotcolors[/QUOTE]

            Sounds good Bertrand. Is there any already existing operational indicator which uses these Plotcolors so I could look at that indicators code? That would help me (I am still learning the whole coding bit.)

            PS: And merry Christmas/schoene Weihnachten!!!

            sandman

            Comment


              #36
              Hello sandman,

              Thank you for your response.

              The following link will take you to a reference sample on multi-colored plots and demonstrates the use of PlotColors: http://www.ninjatrader.com/support/f...ead.php?t=3227

              Please let me know if I may be of further assistance.

              Comment


                #37
                Thanks Bertrand, and also Patrick.

                I got to work with what you provided and that worked out and the plotted line now shows up in the way I expected it to to show up.

                I have enclosed an image of the chart, with the open indicator menu box.

                The last thing I need to resolve is how to code it so that I can adjust the colors of the plotted line (different for rising and falling) in the indicator menu box. Right now it does not do that though all three plots are listed nicely in the indicator menu box. I can adjust the width of the drawn line in the "Average line plot" as well as its dash style but I cannot change the colors. In the open box right now for example I chose yellow green as the color when it is rising, but it remains "green".

                In the attached image I also included the code I put together thus far. Your help to resolve this point would be appreciated. (Keep in mind I am still relatively new in this coding business, so please keep help tips and instructions as simple as possible).

                sandman
                Attached Files

                Comment


                  #38
                  sandman,
                  You are mixing 2 techniques to plot in different colors ;
                  #1) Defining 3 plots with different colors each one, and assigning value only to that we want to show
                  #2) Defining only 1 plot with any color and overriding it with PlotColors
                  On your code you are defining 3 plots ; Average, Falling, Rising
                  but settings values always to average.set(value)
                  ..and then overriding its color with Plotcolor
                  ------------------------------------------------------------------------------------------------
                  Try using the unused plots settings as input variable ;
                  if(Rising(Average) PlotColors[0][0] = Plots[2].Pen.Color;
                  else if(Falling(Average) PlotColors[0][0] = Plots[1].Pen.Color;
                  // if not rising or falling the the default color is already defined on the Average setting

                  Regards,
                  Pablo Maglio
                  www.TheIndicatorStore.com
                  pmaglio
                  NinjaTrader Ecosystem Vendor - The Indicator Store

                  Comment


                    #39
                    Hello Pablo.

                    That was almost too easy to fix based on your instructions. Thank you very much!

                    Last minor point is what do I have to do to be able to adjust the DashStyle through the Indicator Menu box? (I can now adjust the colors of all but the DashStyle is only changeable for the Average line - but then also changes the Style for Rising and Falling conditions).

                    PS: Greetings from Europe!

                    sandman
                    Attached Files

                    Comment


                      #40
                      Originally posted by sandman View Post
                      Hello Pablo.

                      That was almost too easy to fix based on your instructions. Thank you very much!

                      Last minor point is what do I have to do to be able to adjust the DashStyle through the Indicator Menu box? (I can now adjust the colors of all but the DashStyle is only changeable for the Average line - but then also changes the Style for Rising and Falling conditions).

                      PS: Greetings from Europe!

                      sandman
                      Maybe I am misunderstanding your issue, but it seems to me that you are having a problem with the properties of objects.

                      The 3 Plots that you have declared are each independent objects, whose properties have nothing to do with one another. Assigning a property on one plot would and should not have any effect on any other object. If you want a property of any Plot to reflect the property of any other object, you must explicitly assign same, in much the same manner as you assigned to the Average Plot, the color of either the Rising or Falling Plot

                      Comment


                        #41
                        I have now studied the two Advanced Tutorials under the Indicators section and also the tip from Josh on User Definable Color Inputs.

                        In the sample from Josh he creates a colored Rectangle. In the code he uses "DrawRectangle".

                        What I want to create next is to have user definable colors for the candlestick bars. When certain conditions are fulfilled the color of the bar should change.

                        In the "Variables" section of the Code I would include something like this:
                        private Color upCandle_Color = Color.Green;
                        private Color downCandle_Color = Color.Red;

                        In the "Properties" section I have
                        // colors
                        [XmlIgnore()]
                        [Description("Color for Up Candle")]
                        [GridCategory("Candle Colors")]
                        public Color UpCandle_Color
                        {
                        get { return upCandle_Color; }
                        set { upCandle_Color = value; }
                        }

                        // Serialize our Color object
                        [Browsable(true)]
                        public string upCandle_ColorSerialize
                        {
                        get { return NinjaTrader.Gui.Design.SerializableColor.ToString( upCandle_Color); }
                        set { upCandle_Color = NinjaTrader.Gui.Design.SerializableColor.FromStrin g(value); }
                        }
                        - and the same for down_candle.

                        But what do I put into the onBarUpdate section???

                        Josh uses this in his sample:
                        DrawRectangle("rectangle", true, 0, High[0], 5, Low[5], BorderColor, FillColor, 10);

                        How does he know to use the command "DrawRectangle" and "BorderFill"??? And what do I have to use to point to my upCandle/downCandle colors?

                        sandman

                        Comment


                          #42
                          What about using BarColor = upCandle_Color; ?
                          Is this what you are looking for ?

                          Best wishes
                          Pablo Maglio
                          www.TheIndicatorStore.com
                          pmaglio
                          NinjaTrader Ecosystem Vendor - The Indicator Store

                          Comment


                            #43
                            Originally posted by sandman View Post
                            I have now studied the two Advanced Tutorials under the Indicators section and also the tip from Josh on User Definable Color Inputs.

                            In the sample from Josh he creates a colored Rectangle. In the code he uses "DrawRectangle".

                            What I want to create next is to have user definable colors for the candlestick bars. When certain conditions are fulfilled the color of the bar should change.

                            In the "Variables" section of the Code I would include something like this:
                            private Color upCandle_Color = Color.Green;
                            private Color downCandle_Color = Color.Red;

                            In the "Properties" section I have
                            // colors
                            [XmlIgnore()]
                            [Description("Color for Up Candle")]
                            [GridCategory("Candle Colors")]
                            public Color UpCandle_Color
                            {
                            get { return upCandle_Color; }
                            set { upCandle_Color = value; }
                            }

                            // Serialize our Color object
                            [Browsable(true)]
                            public string upCandle_ColorSerialize
                            {
                            get { return NinjaTrader.Gui.Design.SerializableColor.ToString( upCandle_Color); }
                            set { upCandle_Color = NinjaTrader.Gui.Design.SerializableColor.FromStrin g(value); }
                            }
                            - and the same for down_candle.

                            But what do I put into the onBarUpdate section???

                            Josh uses this in his sample:
                            DrawRectangle("rectangle", true, 0, High[0], 5, Low[5], BorderColor, FillColor, 10);

                            How does he know to use the command "DrawRectangle" and "BorderFill"??? And what do I have to use to point to my upCandle/downCandle colors?

                            sandman
                            You use BarColor to change bar colors. Look in the NT Help for the correct syntax.

                            Comment


                              #44
                              PMaglio!

                              A second time where your simplicity solved it in zero point five seconds! That opens a whole new range of forming up the few indicators which I use in a way I find them the easiest to read.

                              Thank you very much! Muchas gracias!!!!

                              sandman

                              Comment


                                #45
                                I now have user definable colors for the candlestick bars; when certain conditions are fulfilled the color of the bar changes. Beautiful.

                                How do I have to address it in the code so that it keeps adjusting/changing this color while the 5-Min bar is in progress; it could change several times during these 5 minutes.

                                Right now, for example, if price goes down the bar is being colored in red. Even though price may go up in the 3rd minute, the bar color remains red when it should now actually change to being green.

                                Hope I am being clear with what I am trying to fix.

                                sandman

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                672 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                379 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                111 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                575 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                582 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X