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

Instead of BarBrushes how to I say BarOutline?

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

    #16
    This is more of a challenge here; I want to allow the user to be able to change the colors and even for myself without going into the code. I know it's done in the properties section. Can you please give me some direction on this part?
    Attached Files

    Comment


      #17
      Hello trdninstyle,

      Use a public variable with the NinjaScriptProperty attribute and XmlIgnore attribute, and serialize it with a second public variable using the Browsable(false) attribute.

      Below are links to the help guide.


      Chelsea B.NinjaTrader Customer Service

      Comment


        #18
        Okay, I read all those items and there all already in there, but I need two areas to color for up & down. Right now, as is there's only one spot to color.
        wouldnt I need to enter something specific twice?
        Attached Files

        Comment


          #19
          Heres what I did, its in the pic
          Attached Files

          Comment


            #20
            Hello trdninstyle,

            Each variable/input should have unique name. Copy the code for each brush and change the name.

            There are two indicators included with NinjaTrader you can use as learning examples.

            Have a look at the code in the Volume profile indicator for the Volume down color, Volume netural color, and Volume up color on lines 70 through 72 and 311 through 342.
            Have a look at the Volume zones indicator for the DownBarColor and UpBarColor on lines 59, 60, 196 through 206, and 223 through 233.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #21
              Okay, I'm going right now to look at that. Is this the right way to create an additional input? I copied/pasted, and it compiled and gave me two inputs. Maybe it's still not the correct way tho?

              But it doesn't color anything tho, let me go look at what u suggested.
              Attached Files

              Comment


                #22
                Hello trdninstyle,

                Yes, you can copy and paste. Just change the variable names and the Name property in the Display attribute.

                Once the brush is created as an input, you can use this in the code where you want that color (in OnBarUpdate()).

                You can assign this to the CandleOutlineBrush or BarBrush or BackgroundBrush, or whatever it is you want to color.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #23
                  I'm definitely making progress here. Please take a look at these pics. It looks as if everything should work now except when I change the colors nothing happens.
                  In the Volume example there is a little different wording,

                  Volume example; [Display(ResourceType = typeof(Custom.Resource), Name = "Opacity", Order = 0, GroupName = "NinjaScriptParameters")]

                  and I have; [Display(Name = "CandleOutlineDownColor", GroupName = "NinjaScriptParameters", Order = 0)]
                  Attached Files

                  Comment


                    #24
                    Hello trdninstyle,

                    ResourceType = typeof(Custom.Resource) in the Display attribute is a property NinjaTrader uses for language translations. You don't have to include that, and you can just leave it out.


                    What properties are you assigning to these brush variables?

                    Are you assigning CandleOutlineBrushes[0] to this brush variable?

                    May we see the code where these brush variables are assigned to something?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #25
                      I copied / paste most of the code so you can discern where my error may be. Thank you.

                      namespace NinjaTrader.NinjaScript.Indicators.Trdnstyle
                      {
                      public class TwoBarRevUpDown : Indicator
                      {



                      protected override void OnStateChange()
                      {
                      if (State == State.SetDefaults)
                      {
                      Description = @"Paints a Two Bar Reversal Up and Down Yellow White";
                      Name = "2BarRevUpDown";
                      Calculate = Calculate.OnBarClose;
                      IsOverlay = true;
                      DisplayInDataBox = true;
                      DrawOnPricePanel = true;
                      DrawHorizontalGridLines = true;
                      DrawVerticalGridLines = true;
                      PaintPriceMarkers = true;
                      CandleOutlineDownBrush = Brushes.White;
                      CandleOutlineUpBrush = Brushes.Yellow;



                      ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                      //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                      //See Help Guide for additional information.
                      IsSuspendedWhileInactive = true;


                      }
                      else if (State == State.Configure)
                      {

                      // brushColor[i]
                      }
                      }

                      protected override void OnBarUpdate()
                      {
                      if(CurrentBar<2) return;

                      if(Close[1] > Open[1] && High[0] > High[1] && Close[0] < Close[1] && BarBrushes[2] != Brushes.Yellow)

                      {
                      CandleOutlineBrushes[0] = Brushes.Yellow;
                      CandleOutlineBrushes[1] = Brushes.Yellow;
                      }

                      else


                      if(Close[1] < Open[1] && Low[0] < Low[1] && Close[0] > Close[1] && BarBrushes[2] != Brushes.White)


                      {
                      CandleOutlineBrushes[0] = Brushes.White;
                      CandleOutlineBrushes[1] = Brushes.White;
                      }

                      }


                      I copied / paste most of the code so you can discern where my error may be. Thank you.


                      region Properties
                      // Create our user definable color input
                      [XmlIgnore()]
                      [Display(Name = "CandleOutlineDownColor", GroupName = "NinjaScriptParameters", Order = 0)]
                      public Brush CandleOutlineDownBrush { get; set;}


                      // Serialize our Color object Hardcoded Brushes?
                      [Browsable(false)]
                      public string CandleOutlineDownBrushSerialize
                      {
                      get { return Serialize.BrushToString(CandleOutlineDownBrush); }
                      set { CandleOutlineDownBrush = Serialize.StringToBrush(value); }
                      }

                      // Create our user definable color input
                      [XmlIgnore()]
                      [Display(Name = "CandleOutlinUpColor", GroupName = "NinjaScriptParameters", Order = 0)]
                      public Brush CandleOutlineUpBrush { get; set;}


                      // Serialize our Color object Hardcoded Brushes?
                      [Browsable(false)]
                      public string CandleOutlineUpBrushSerialize
                      {
                      get { return Serialize.BrushToString(CandleOutlineUpBrush); }
                      set { CandleOutlineUpBrush = Serialize.StringToBrush(value); }
                      }

                      #endregion
                      }​

                      Comment


                        #26
                        Hello trdninstyle,

                        To clarify an assignment is when you are setting a value to something.

                        MyVariable = MyOtherVariable;

                        This is an assignment.

                        if (MyVariable == MyOtherVariable)
                        {
                        }

                        This a comparison in an 'if' branching command.

                        MyMethodCall();

                        This is a method call.


                        Lets think it through.

                        What are you trying to color in your script?

                        On what line are you setting that value?
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #27
                          What are you trying to color in your script? CandleOutline

                          On what line are you setting that value? Line 54, 55, under the description column

                          I'm missing it right now. I have to clarify an assignment, so it carries it out. It needs to know where the value is.

                          Comment


                            #28
                            Hello trdninstyle,

                            The candle outline is CandleOutlineBrushes[0].

                            Where you do see CandleOutlineBrushes[0] being assigned a value in the code?

                            Can you copy the first line of code where CandleOutlineBrushes[0] is being assigned a value with your reply?
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #29
                              CandleOutlineBrushes[0] = Brushes.White;
                              CandleOutlineBrushes[1] = Brushes.White;

                              CandleOutlineBrushes[0] = Brushes.Yellow;
                              CandleOutlineBrushes[1] = Brushes.Yellow;

                              {
                              get { return Serialize.BrushToString(CandleOutlineDownBrush); } < do I place [0] in there? and [1] for the previous bar?
                              set { CandleOutlineDownBrush = Serialize.StringToBrush(value); }
                              }

                              Comment


                                #30
                                Hello trdninstyle,

                                Currently, you are assigning CandleOutlineBrushes[0] to Brushes.White.

                                Assign CandleOutlineBrushes[0] the value of your variable instead of Brushes.White.

                                CandleOutlineBrushes[0] = CandleOutlineDownBrush;

                                Now the color of the outline will have the color that was assigned to the input variable.

                                Do this where where you want to use that color.
                                Chelsea B.NinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by usazencort, Today, 01:16 AM
                                0 responses
                                1 view
                                0 likes
                                Last Post usazencort  
                                Started by kaywai, 09-01-2023, 08:44 PM
                                5 responses
                                603 views
                                0 likes
                                Last Post NinjaTrader_Jason  
                                Started by xiinteractive, 04-09-2024, 08:08 AM
                                6 responses
                                22 views
                                0 likes
                                Last Post xiinteractive  
                                Started by Pattontje, Yesterday, 02:10 PM
                                2 responses
                                21 views
                                0 likes
                                Last Post Pattontje  
                                Started by flybuzz, 04-21-2024, 04:07 PM
                                17 responses
                                230 views
                                0 likes
                                Last Post TradingLoss  
                                Working...
                                X