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.
Is there any way to resolve this error?
i attach the indicator, also here the code I made:
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

Comment