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

Question On Indicator Defaults

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

    Question On Indicator Defaults

    I recently received a custom indicator where I set all the parameters according to my specifications, then right clicked on it to save the settings as the default. For some reason when I re-open the workspace I saved or re-apply the indicator one of the parameters changed back to the original default. So each time I have to reset that one parameter. Is there something in the code that needs to be modified?

    Regards
    Chuck

    #2
    Hello,

    Just checking here, have you tried right clicking and setting new defaults? Or does this not work?

    I look forward to assisting you further.

    Comment


      #3
      Originally posted by NinjaTrader_Brett View Post
      Hello,

      Just checking here, have you tried right clicking and setting new defaults? Or does this not work?

      I look forward to assisting you further.
      Yes Brett. I've attached a screen shot. The default for "Color Bars" in the "Visual" section was set by the programmer to "True". I wanted to change it to false so I changed it and then right clicked it to save it as the default. But each time I re-apply the indicator or open a saved workspace the indicator reverts the default back to "True".

      Regards
      Chuck
      Attached Files

      Comment


        #4
        Hello,

        Looks like the programmer might have this coded slightly wrong then on this parameter so its not correctly saving the indicator state.

        Please have the programmer or you contact me with source code of the inicator so that I can look into what is coded wrong if he/you are unable to find the issue.

        If you need to send it in for me to look into send to support at ninjatrader dot com ATTN: Brett reference this forum post.

        Comment


          #5
          Having worked through something similar recently, the first thing that comes to my mind is to ask whether or not you can save and restore the parameter.

          Try setting the parameter to anything non-default, and then save your chart as a template. Next, open a new chart and apply that template. Do you get the parameter you saved? If not, then the indicator is not properly serializing its parameter and that is your problem.

          Given that it is a BOOL, possibly an unwanted [XmlIgnore]?

          --EV

          Comment


            #6
            Just trying to find out why this is happening to me in my new indicator. I can't figure it out. The parameters AsianFinish and UsBegin are TimeSpan by type, and I don't initialize them at all in the code.

            Every time I close and re-open NT7, the indicator on the chart loses its values for these parameters.

            I tried setting the parameters to useful values and saving the indicator in a template, but reloading the template into another chart shows that the parameter values are lost.

            I know I can set the indicator panel defaults with a right-click, but the parameter values should survive from day to day without that, surely?

            Here's the code:

            Code:
            using System;
            using System.ComponentModel;
            using System.Diagnostics;
            using System.Drawing;
            using System.Drawing.Drawing2D;
            using System.Xml.Serialization;
            using NinjaTrader.Cbi;
            using NinjaTrader.Data;
            using NinjaTrader.Gui.Chart;
            
            namespace NinjaTrader.Indicator
            {
                /// <summary>
                /// Sets the high and the low of the Asian and London sessions
                /// for the rest of the session
                /// </summary>
                [Description("Sets the high and the low of the Asian and London sessions " 
                            + "for the rest of the session")]
                public class ForexSessionHL : Indicator
                {
                    private TimeSpan asianFinish;
                    private TimeSpan usBegin;
                    private DateTime asianFinish2;
                    private DateTime usBegin2;
                    private double maxAsianHigh = Double.MinValue;
                    private double minAsianLow = Double.MaxValue;
                    private double maxLondonHigh = Double.MinValue;
                    private double minLondonLow = Double.MaxValue;
                    private bool doneReset = false;
            
                    protected override void Initialize()
                    {
                        Add(new Plot(Color.FromKnownColor(KnownColor.LightSeaGreen), 
                            PlotStyle.Line, "AsianSessionHigh"));
                        Add(new Plot(Color.FromKnownColor(KnownColor.LightSeaGreen), 
                            PlotStyle.Line, "AsianSessionLow"));
                        Add(new Plot(Color.FromKnownColor(KnownColor.BlueViolet), 
                            PlotStyle.Line, "LondonSessionHigh"));
                        Add(new Plot(Color.FromKnownColor(KnownColor.BlueViolet), 
                            PlotStyle.Line, "LondonSessionLow"));
                        Overlay = true;
                        PaintPriceMarkers = false;
                    }
                    
                    
                    protected override void OnBarUpdate()
                    {
                        if (Bars.BarsSinceSession == 0)
                        {
                            DateTime midnight = Time[0].AddDays(1);
                            midnight = midnight.AddHours(-1 * Time[0].Hour);
                            midnight = midnight.AddMinutes(-1 * Time[0].Minute);
                            asianFinish2 = midnight.Add(asianFinish);
                            usBegin2 = midnight.Add(usBegin);
                            maxAsianHigh = Double.MinValue;
                            minAsianLow = Double.MaxValue;
                            maxLondonHigh = Double.MinValue;
                            minLondonLow = Double.MaxValue;
                        }
                        if (Time[0].CompareTo(Time[Bars.BarsSinceSession]) >= 0
                            && Time[0].CompareTo(asianFinish2) <= 0)
                        {
                            if (High[0] > maxAsianHigh) maxAsianHigh = High[0];
                            if (Low[0] < minAsianLow) minAsianLow = Low[0];
                        }
                        if (Time[0].CompareTo(asianFinish2) >= 0
                            && Time[0].CompareTo(usBegin2) <= 0)
                        {
                            if (High[0] > maxLondonHigh) maxLondonHigh = High[0];
                            if (Low[0] < minLondonLow) minLondonLow = Low[0];
                        }
                        if (maxAsianHigh > Double.MinValue && Bars.BarsSinceSession > 1)
                        {
                            AsianSessionHigh.Set(maxAsianHigh);
                        }
                        if (minAsianLow < Double.MaxValue && Bars.BarsSinceSession > 1)
                        {
                               AsianSessionLow.Set(minAsianLow);
                        }
                        if (maxLondonHigh > Double.MinValue && Bars.BarsSinceSession > 1)
                        {
                            LondonSessionHigh.Set(maxLondonHigh);
                        }
                        if (minLondonLow < Double.MaxValue && Bars.BarsSinceSession > 1)
                        {
                               LondonSessionLow.Set(minLondonLow);
                        }
                    }
                    
                    #region Properties
                    [Browsable(false)]
                    [XmlIgnore()]    
                    public DataSeries AsianSessionHigh
                    {
                        get { return Values[0]; }
                    }
                    [Browsable(false)]
                    [XmlIgnore()]
                    public DataSeries AsianSessionLow
                    {
                        get { return Values[1]; }
                    }
                    [Browsable(false)]
                    [XmlIgnore()]    
                    public DataSeries LondonSessionHigh
                    {
                        get { return Values[2]; }
                    }
                    [Browsable(false)]
                    [XmlIgnore()]
                    public DataSeries LondonSessionLow
                    {
                        get { return Values[3]; }
                    }
            
                    [Description("Asian / London session change-over")]
                    [GridCategory("Parameters")]
                    public TimeSpan AsianFinish
                    {
                        get { return asianFinish; }
                        set { asianFinish = value; }
                    }
                    
                    [Description("US session start")]
                    [GridCategory("Parameters")]
                    public TimeSpan UsBegin
                    {
                        get { return usBegin; }
                        set { usBegin = value; }
                    }
                    
                    #endregion
                }
            }
            Last edited by adamus; 02-05-2013, 04:40 AM.

            Comment


              #7
              We do not have a supported/documented method or serializing with TimeSpan, however you can see a users examples from the following link:

              MatthewNinjaTrader Product Management

              Comment


                #8
                OK great, so I'm not going senile.

                Thanks v much

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Stanfillirenfro, Today, 07:23 AM
                1 response
                2 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by cmtjoancolmenero, Yesterday, 03:58 PM
                2 responses
                20 views
                0 likes
                Last Post cmtjoancolmenero  
                Started by olisav57, Yesterday, 07:39 PM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by cocoescala, 10-12-2018, 11:02 PM
                7 responses
                943 views
                0 likes
                Last Post Jquiroz1975  
                Started by oviejo, Today, 12:28 AM
                1 response
                12 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Working...
                X