Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Opening Price (R1) indicator by bobc635

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

    Opening Price (R1) indicator by bobc635

    Per the explanation of this indicator https://ninjatraderecosystem.com/use...ning-price-r1/, text can be used to label the price and it shows different colors.

    I've gotten the text component to work and you can CHOOSE different colors (My brush). However, when I save something as a template, the time, duration and text entries remain, but the color is always DarkOrange rather than the color I selected when the template was saved.

    This makes it that if I have 5 different Opening Prices saved, I have to go in each day (or after shutting down Ninja) to update the color. Is that a flaw with how the template is used for this indicator?

    Please advise.

    #2
    Hello wickcity,

    It sounds like you may not have a serialization property for the brush. Please do the folllowing and then make sure your code looks like the generated code for the brush.

    In the NinjaScript editor right click on the indicators folder -> New
    In the user input screen make a brush user input with the same name that you use in your script
    Click Generate
    Scroll to the Properties region and expand it
    You should see code like the following, your brushes code needs to look like this:


    Code:
    protected override void OnStateChange()
    {
        if (State == State.SetDefaults)
        {
            MyBrush = Brushes.Orange;
        }
    }​
    
    
    [NinjaScriptProperty]
    [XmlIgnore]
    [Display(Name="MyBrush", Order=1, GroupName="Parameters")]
    public Brush MyBrush
    { get; set; }
    
    [Browsable(false)]
    public string MyBrushSerializable
    {
        get { return Serialize.BrushToString(MyBrush); }
        set { MyBrush = Serialize.StringToBrush(value); }
    }​
    JesseNinjaTrader Customer Service

    Comment


      #3
      I really appreciate the response, but this sounds like a different language to me.

      Also, when I right click on Indicators, it wants to know if I want to create a new indicator or create a new folder.

      I've tried to follow the steps, but can't seem to get the results I'm looking for. Might there be a video somewhere showing the step-by-step actions? If not, I appreciate your time.

      Comment


        #4
        Hello wickcity,

        You would use the new indicator wizard to create generated code for user inputs.

        I am not aware of a video that would be specific to the script you are creating, for a brush to be able to be saved it needs to be in the format that I had provided in the last reply. Is your brushes code in that format?
        JesseNinjaTrader Customer Service

        Comment


          #5
          Thanks for your response, Jesse. Is this the format you're referring to? This is inside the OpeningPrice indicator in the Properties section.



          [Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
          [XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
          public double o
          {
          get; set;
          }
          [XmlIgnore]
          [Display(Name="MyBrush", Description="Color of the Event Marker", Order=1, GroupName="Parameters")]
          public Brush MyBrush
          { get; set; }

          [Browsable(false)]
          public string MyBrushSerializable
          {
          get { return Serialize.BrushToString(MyBrush); }
          set { MyBrush = Serialize.StringToBrush(value); }
          }​

          Comment


            #6
            Hello wickcity,

            Did you make that change to the file you previously linked? The file you linked originally has the brush serialization commented out. For a brush to be saved it needs to look exactly like what I had provided, you need to uncomment the serialization property called MyBrushSerializable and recompile for that brush to be able to be saved.
            JesseNinjaTrader Customer Service

            Comment


              #7
              I know JUST ENOUGH about code to be dangerous -- and likely ruin the indicator (could remove and reimport...).

              Which lines am I to uncomment?
              How do I do a recompile?

              Thank you for your patience, Jesse.

              Comment


                #8
                Hello wickcity,

                In the original file that would be the following lines


                // [Browsable(false)]
                // public string MyBrushSerializable
                // {
                // get { return Serialize.BrushToString(MyBrush); }
                // set { MyBrush = Serialize.StringToBrush(value); }
                // }

                It should look identical to this:

                [XmlIgnore]
                [Display(Name="MyBrush", Description="Color of the Event Marker", Order=1, GroupName="Parameters")]
                public Brush MyBrush
                { get; set; }

                [Browsable(false)]
                public string MyBrushSerializable
                {
                get { return Serialize.BrushToString(MyBrush); }
                set { MyBrush = Serialize.StringToBrush(value); }
                }​​​
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  I'm not sure what happened, but I did a recompile and it's now saving the templates. I really appreciate your assistance, Jesse. I'm going to shut down, restart and hold my breath that the templates (and colors) hold. Even if they don't, I'll likely not bother you again. : )

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by angelgrace11, Today, 08:10 PM
                  0 responses
                  4 views
                  0 likes
                  Last Post angelgrace11  
                  Started by cryfgg, Today, 05:25 PM
                  0 responses
                  9 views
                  0 likes
                  Last Post cryfgg
                  by cryfgg
                   
                  Started by xiinteractive, 02-02-2023, 04:25 PM
                  6 responses
                  242 views
                  0 likes
                  Last Post xiinteractive  
                  Started by cryfgg, 12-01-2023, 10:12 AM
                  7 responses
                  123 views
                  0 likes
                  Last Post Rxxar
                  by Rxxar
                   
                  Started by RayHouston, Today, 04:45 PM
                  0 responses
                  13 views
                  0 likes
                  Last Post RayHouston  
                  Working...
                  X