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 to save indicator user settings

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

  • superg3
    replied
    Originally posted by bltdavid View Post

    While viewing your indicator's parameters in the property grid, right click for the context menu.

    NinjaTrader supports the saving of your customized values as the new default values for your
    indicator, but will only ever save 1 default template per indicator.

    The defaults are stored in a single XML file in the folder "templates/Indicator".

    TIP:
    If you see strange errors after upgrading to a new version of your indicator, one of the solutions
    might be to delete the old XML template file in "templates/Indicator" folder.

    Look here:
    https://ninjatrader.com/support/help...t_defaults.htm

    Read sections:
    Understanding indicator default settings
    Saving Custom Indicator Settings

    Pay attention to where it shows you to "Right Click" ...
    Thank you for the info bltdavid!

    Leave a comment:


  • bltdavid
    replied
    Originally posted by superg3 View Post
    Hi, the indicator works as expected but the values set in parameters are not saved, when the script is reloaded or after NT is restarted the settings como back to Variables values.
    Please could you tell me how to fix that?
    While viewing your indicator's parameters in the property grid, right click for the context menu.

    NinjaTrader supports the saving of your customized values as the new default values for your
    indicator, but will only ever save 1 default template per indicator.

    The defaults are stored in a single XML file in the folder "templates/Indicator".

    TIP:
    If you see strange errors after upgrading to a new version of your indicator, one of the solutions
    might be to delete the old XML template file in "templates/Indicator" folder.

    Look here:
    https://ninjatrader.com/support/help...t_defaults.htm

    Read sections:
    Understanding indicator default settings
    Saving Custom Indicator Settings

    Pay attention to where it shows you to "Right Click" ...
    Last edited by bltdavid; 03-01-2019, 09:47 AM.

    Leave a comment:


  • superg3
    replied
    Thank you very much!

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello superg3,

    Any public properties with the [XmlIgnore()] attribute applied will not be saved in xml files such as templates or workspaces. Remove this attribute from any serialization type such as strings, doubles, integers, and booleans. Any other types should likely be serialized.

    https://ninjatrader.com/support/help...lor_inputs.htm

    As a tip, To export a NinjaTrader 7 NinjaScript so this may be shared and imported by the recipient do the following:
    1. Click File -> Utilities -> Export NinjaScript
    2. Enter a unique name for the file in the value for 'File name:'
    3. Select the strategy from the objects list on the left -> click the right facing arrow ">" to add the strategy to the export
    4. Click the 'Export' button -> click 'yes' to add any referenced indicators to the export -> click OK to clear the export location message
    By default your exported file will be in the following location:
    • (My) Documents\NinjaTrader 7\bin\Custom\ExportNinjaScript\<export_file_name.z ip>
    Below is a link to the help guide on Exporting NinjaScripts.
    http://www.ninjatrader.com/support/h...nt7/export.htm

    Leave a comment:


  • superg3
    started a topic Help to save indicator user settings

    Help to save indicator user settings

    Hi, the indicator works as expected but the values set in parameters are not saved, when the script is reloaded or after NT is restarted the settings como back to Variables values.
    Please could you tell me how to fix that?

    My code:

    Code:
    #region Using declarations
    using System;
    using System.Diagnostics;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.ComponentModel;
    using System.Xml.Serialization;
    using NinjaTrader.Data;
    using NinjaTrader.Gui.Chart;
    #endregion
    
    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {
        /// <summary>
        /// Volume is simply the number of shares (or contracts) traded during a specified time frame (e.g. hour, day, week, month, etc).
        /// </summary>
    
        [Description("Volume is simply the number of shares (or contracts) traded during a specified time frame (e.g. hour, day, week, month, etc).")]
        public class VolLoBo : Indicator
    
        {
            #region Variables
            private int VolRelev1 = 200;  
            private Color ColorVolRel1 = Color.Green;
            private int VolRelev2 = 320;
            private Color ColorVolRel2 = Color.Red;
            #endregion
    
            /// <summary>
            /// This method is used to configure the indicator and is called once before any bar data is loaded.
            /// </summary>
    
            protected override void Initialize()
            {
                Add(new Plot(new Pen(Color.Blue, 2), PlotStyle.Bar, "Volume"));
                Add(new Line(Color.DarkGray, 0, "Zero line"));                
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
    
            protected override void OnBarUpdate()
            {
                Value.Set(Volume[0]);
    
                if (Volume[0] >= VolRelev1)                
                {
                    PlotColors[0][0] = ColorVolRel1;  
                }
    
                if (Volume[0] >= VolRelev2)                 
                {
                    PlotColors[0][0] = ColorVolRel2;  
                }
            }
    
            #region Properties
            [XmlIgnore()]
            [Description("Color V. Relevante")]
            [GridCategory("Parameters")]
            public Color Color_V_Relevante
            {
                get { return ColorVolRel1; }
                set { ColorVolRel1 = value; }
            }
    
            [Browsable(false)]
            public string ColorVolRel1Serializable
            {
                get { return NinjaTrader.Gui.Design.SerializableColor.ToString(ColorVolRel1); }
                set { ColorVolRel1 = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
            }
    
            [XmlIgnore()]
            [Description("Color Super Volumen")]
            [GridCategory("Parameters")]
            public Color Color_SuperVolumen
            {
                get { return ColorVolRel2; }
                set { ColorVolRel2 = value; }
            }
    
            [Browsable(false)]
            public string ColorVolRel2Serializable
            {
                get { return NinjaTrader.Gui.Design.SerializableColor.ToString(ColorVolRel2); }
                set { ColorVolRel2 = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
            }
    
            [XmlIgnore()]
            [Description("Valor Volumen Relevante")]
            [GridCategory("Parameters")]
            public int V_Relevante
            {
                get { return VolRelev1; }
                set { VolRelev1 = value; }
            }
    
            [XmlIgnore()]
            [Description("Valor Volumen Relevante")]
            [GridCategory("Parameters")]
            public int SuperVolumen
            {
                get { return VolRelev2; }
                set { VolRelev2 = value; }
            }
    
            #endregion
        }
    }
    
    #region NinjaScript generated code. Neither change nor remove.
    // This namespace holds all indicators and is required. Do not change it.
    namespace NinjaTrader.Indicator
    {
        public partial class Indicator : IndicatorBase
        {
            private VolLoBo[] cacheVolLoBo = null;
    
            private static VolLoBo checkVolLoBo = new VolLoBo();
    
            /// <summary>
            /// Volume is simply the number of shares (or contracts) traded during a specified time frame (e.g. hour, day, week, month, etc).
            /// </summary>
            /// <returns></returns>
            public VolLoBo VolLoBo(Color color_SuperVolumen, Color color_V_Relevante, int superVolumen, int v_Relevante)
            {
                return VolLoBo(Input, color_SuperVolumen, color_V_Relevante, superVolumen, v_Relevante);
            }
    
            /// <summary>
            /// Volume is simply the number of shares (or contracts) traded during a specified time frame (e.g. hour, day, week, month, etc).
            /// </summary>
            /// <returns></returns>
            public VolLoBo VolLoBo(Data.IDataSeries input, Color color_SuperVolumen, Color color_V_Relevante, int superVolumen, int v_Relevante)
            {
                if (cacheVolLoBo != null)
                    for (int idx = 0; idx < cacheVolLoBo.Length; idx++)
                        if (cacheVolLoBo[idx].Color_SuperVolumen == color_SuperVolumen && cacheVolLoBo[idx].Color_V_Relevante == color_V_Relevante && cacheVolLoBo[idx].SuperVolumen == superVolumen && cacheVolLoBo[idx].V_Relevante == v_Relevante && cacheVolLoBo[idx].EqualsInput(input))
                            return cacheVolLoBo[idx];
    
                lock (checkVolLoBo)
                {
                    checkVolLoBo.Color_SuperVolumen = color_SuperVolumen;
                    color_SuperVolumen = checkVolLoBo.Color_SuperVolumen;
                    checkVolLoBo.Color_V_Relevante = color_V_Relevante;
                    color_V_Relevante = checkVolLoBo.Color_V_Relevante;
                    checkVolLoBo.SuperVolumen = superVolumen;
                    superVolumen = checkVolLoBo.SuperVolumen;
                    checkVolLoBo.V_Relevante = v_Relevante;
                    v_Relevante = checkVolLoBo.V_Relevante;
    
                    if (cacheVolLoBo != null)
                        for (int idx = 0; idx < cacheVolLoBo.Length; idx++)
                            if (cacheVolLoBo[idx].Color_SuperVolumen == color_SuperVolumen && cacheVolLoBo[idx].Color_V_Relevante == color_V_Relevante && cacheVolLoBo[idx].SuperVolumen == superVolumen && cacheVolLoBo[idx].V_Relevante == v_Relevante && cacheVolLoBo[idx].EqualsInput(input))
                                return cacheVolLoBo[idx];
    
                    VolLoBo indicator = new VolLoBo();
                    indicator.BarsRequired = BarsRequired;
                    indicator.CalculateOnBarClose = CalculateOnBarClose;
    #if NT7
                    indicator.ForceMaximumBarsLookBack256 = ForceMaximumBarsLookBack256;
                    indicator.MaximumBarsLookBack = MaximumBarsLookBack;
    #endif
                    indicator.Input = input;
                    indicator.Color_SuperVolumen = color_SuperVolumen;
                    indicator.Color_V_Relevante = color_V_Relevante;
                    indicator.SuperVolumen = superVolumen;
                    indicator.V_Relevante = v_Relevante;
                    Indicators.Add(indicator);
                    indicator.SetUp();
    
                    VolLoBo[] tmp = new VolLoBo[cacheVolLoBo == null ? 1 : cacheVolLoBo.Length + 1];
                    if (cacheVolLoBo != null)
                        cacheVolLoBo.CopyTo(tmp, 0);
                    tmp[tmp.Length - 1] = indicator;
                    cacheVolLoBo = tmp;
                    return indicator;
                }
            }
        }
    }
    
    // This namespace holds all market analyzer column definitions and is required. Do not change it.
    namespace NinjaTrader.MarketAnalyzer
    {
        public partial class Column : ColumnBase
        {
            /// <summary>
            /// Volume is simply the number of shares (or contracts) traded during a specified time frame (e.g. hour, day, week, month, etc).
            /// </summary>
            /// <returns></returns>
            [Gui.Design.WizardCondition("Indicator")]
            public Indicator.VolLoBo VolLoBo(Color color_SuperVolumen, Color color_V_Relevante, int superVolumen, int v_Relevante)
            {
                return _indicator.VolLoBo(Input, color_SuperVolumen, color_V_Relevante, superVolumen, v_Relevante);
            }
    
            /// <summary>
            /// Volume is simply the number of shares (or contracts) traded during a specified time frame (e.g. hour, day, week, month, etc).
            /// </summary>
            /// <returns></returns>
            public Indicator.VolLoBo VolLoBo(Data.IDataSeries input, Color color_SuperVolumen, Color color_V_Relevante, int superVolumen, int v_Relevante)
            {
                return _indicator.VolLoBo(input, color_SuperVolumen, color_V_Relevante, superVolumen, v_Relevante);
            }
        }
    }
    
    // This namespace holds all strategies and is required. Do not change it.
    namespace NinjaTrader.Strategy
    {
        public partial class Strategy : StrategyBase
        {
            /// <summary>
            /// Volume is simply the number of shares (or contracts) traded during a specified time frame (e.g. hour, day, week, month, etc).
            /// </summary>
            /// <returns></returns>
            [Gui.Design.WizardCondition("Indicator")]
            public Indicator.VolLoBo VolLoBo(Color color_SuperVolumen, Color color_V_Relevante, int superVolumen, int v_Relevante)
            {
                return _indicator.VolLoBo(Input, color_SuperVolumen, color_V_Relevante, superVolumen, v_Relevante);
            }
    
            /// <summary>
            /// Volume is simply the number of shares (or contracts) traded during a specified time frame (e.g. hour, day, week, month, etc).
            /// </summary>
            /// <returns></returns>
            public Indicator.VolLoBo VolLoBo(Data.IDataSeries input, Color color_SuperVolumen, Color color_V_Relevante, int superVolumen, int v_Relevante)
            {
                if (InInitialize && input == null)
                    throw new ArgumentException("You only can access an indicator with the default input/bar series from within the 'Initialize()' method");
    
                return _indicator.VolLoBo(input, color_SuperVolumen, color_V_Relevante, superVolumen, v_Relevante);
            }
        }
    }
    #endregion
    Thanks in advance

Latest Posts

Collapse

Topics Statistics Last Post
Started by gabberdim, Today, 09:14 AM
1 response
3 views
0 likes
Last Post NinjaTrader_Gaby  
Started by ZeroKuhl, 05-30-2024, 10:22 AM
2 responses
15 views
0 likes
Last Post ZeroKuhl  
Started by kiss987, 05-16-2018, 02:19 AM
13 responses
2,847 views
0 likes
Last Post NinjaTrader_Jesse  
Started by icebergdelphi, 06-12-2024, 04:01 PM
5 responses
33 views
0 likes
Last Post NinjaTrader_Gaby  
Started by merzo, Today, 08:48 AM
1 response
8 views
0 likes
Last Post NinjaTrader_Clayton  
Working...
X