Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Error account selection from indicator to strategy

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

    Error account selection from indicator to strategy

    Hello NinjaTrader Team,

    I am trying to incorporate an indicator into my strategy that copies orders from a master account to other accounts. I would like to be able to call this indicator from within the strategy and select the accounts.

    I have attempted to implement this in various ways, but I always encounter the same error: "Error on getting value for property for NinjaScript: Object reference not set to an instance of an object."





    I want to be able to access the properties of the indicator from my strategy and select the master account and the other accounts to copy (up to 9 accounts). I believe the issue stems from the null reference of the indicator, which is causing the error since initially no account is selected.

    Click image for larger version

Name:	image.png
Views:	116
Size:	59.7 KB
ID:	1304911


    Is there any way to resolve this error?



    i attach the indicator, also here the code I made:


    Code:
    public class PRUEBAS : Strategy
        {
            
    
            #region Indicators
    
            private NinjaTrader.NinjaScript.Indicators.TRADINGNASDAQ.SimpleTradeCopier ReplicatorTN1;
            
            #endregion
    
            
            protected override void OnStateChange()
            {
    
                if (State == State.SetDefaults)
                {
                    ****CODE****
                    
                }
                        
                #region Configure Indicators
                
                else if (State == State.Configure)
                {
                    ****CODE****
                }
                
                else if (State == State.DataLoaded)
                {                                
                   ****CODE****
                }
                
            protected override void OnBarUpdate()
            {
                Cuenta_Master = SimpleTradeCopier.MasterAccount_name;
                Cuenta_1 = SimpleTradeCopier.Accountname_1;
                Cuenta_2 = SimpleTradeCopier.Accountname_2;
                Cuenta_3 = SimpleTradeCopier.Accountname_3;
                Cuenta_4 = SimpleTradeCopier.Accountname_4;
                Cuenta_5 = SimpleTradeCopier.Accountname_5;
                Cuenta_6 = SimpleTradeCopier.Accountname_6;
                Cuenta_7 = SimpleTradeCopier.Accountname_7;
                Cuenta_8 = SimpleTradeCopier.Accountname_8;
                Cuenta_9 = SimpleTradeCopier.Accountname_9;
                
    
    
    
            }
            
            #region Properties
    
    
            #region 10. Replicator / Replicadora
            
            [RefreshProperties(RefreshProperties.All)]
            [Display(Name="Active Replicator / Activar Replicadora", Description="Determine if Replicator is active / Determina si Replicadora está activo.", Order=1, GroupName="10. Replicator / Replicadora")]
            public bool Replicator
            { get; set; }
            
            [NinjaScriptProperty]
            [Display(Name="Copy from this Account ",                                 Order=2, GroupName="10. Replicator / Replicadora")]
            [TypeConverter(typeof(NinjaTrader.NinjaScript.AccountNameConverter))]
            public string Cuenta_Master { get; set; }
            
            [NinjaScriptProperty]
            [Display(Name="To Account 1",                                             Order=3, GroupName="10. Replicator / Replicadora")]
            [TypeConverter(typeof(NinjaTrader.NinjaScript.AccountNameConverter))]
            public string Cuenta_1 { get; set; }
            
            [NinjaScriptProperty]
            [Display(Name="To Account 2",                                             Order=4,  GroupName="10. Replicator / Replicadora")]
            [TypeConverter(typeof(NinjaTrader.NinjaScript.AccountNameConverter))]
            public string Cuenta_2 { get; set; }
            
            [NinjaScriptProperty]
            [Display(Name="To Account 3",                                             Order=5,  GroupName="10. Replicator / Replicadora")]
            [TypeConverter(typeof(NinjaTrader.NinjaScript.AccountNameConverter))]
            public string Cuenta_3 { get; set; }
            
            [NinjaScriptProperty]
            [Display(Name="To Account 4",                                             Order=6,  GroupName="10. Replicator / Replicadora")]
            [TypeConverter(typeof(NinjaTrader.NinjaScript.AccountNameConverter))]
            public string Cuenta_4 { get; set; }
            
            [NinjaScriptProperty]
            [Display(Name="To Account 5",                                             Order=7,  GroupName="10. Replicator / Replicadora")]
            [TypeConverter(typeof(NinjaTrader.NinjaScript.AccountNameConverter))]
            public string Cuenta_5 { get; set; }
            
            [NinjaScriptProperty]
            [Display(Name="To Account 6",                                             Order=8,  GroupName="10. Replicator / Replicadora")]
            [TypeConverter(typeof(NinjaTrader.NinjaScript.AccountNameConverter))]
            public string Cuenta_6 { get; set; }
            
            [NinjaScriptProperty]
            [Display(Name="To Account 7",                                             Order=9,  GroupName="10. Replicator / Replicadora")]
            [TypeConverter(typeof(NinjaTrader.NinjaScript.AccountNameConverter))]
            public string Cuenta_7 { get; set; }
            
            [NinjaScriptProperty]
            [Display(Name="To Account 8",                                             Order=10,  GroupName="10. Replicator / Replicadora")]
            [TypeConverter(typeof(NinjaTrader.NinjaScript.AccountNameConverter))]
            public string Cuenta_8 { get; set; }
            
            [NinjaScriptProperty]
            [Display(Name="To Account 9",                                             Order=11,  GroupName="10. Replicator / Replicadora")]
            [TypeConverter(typeof(NinjaTrader.NinjaScript.AccountNameConverter))]
            public string Cuenta_9 { get; set; }
    
            #endregion​

    #2
    Hello tradingnasdaqprueba,

    Thank you for your post.

    I believe the issue stems from the null reference of the indicator, which is causing the error since initially no account is selected.
    Can you confirm that these are the exact lines of code causing the object reference error by testing?

    You can confirm by commenting these lines out, then testing if you are still getting the error. Uncomment the lines, then see if the error returns.

    Checking for Null References - https://ninjatrader.com/support/help...references.htm

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    93 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    138 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    123 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    73 views
    0 likes
    Last Post PaulMohn  
    Working...
    X