Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Incorrect recursive properties error

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

    Incorrect recursive properties error

    Okay... when I compile my strategy I get the message:

    "Your strategy likely holds one or more recursive properties which could cause Ninjatrader to crash..."

    Before you tell me I probably have my property lowercased or with the same name as one of my variables... let me assure you I do not. I have searched the threads and seen where other people had this error and it was always due to some novice programming mistake.

    Here is my setup:

    I have a class CoreOrder that encapsulates all the variables and methods for an order.
    I then also have CoreStrat, which is my base class for all my strategies.

    Now, in my CoreOrder class I have a variable:

    private int stopType = 1; // 0=fixed, 1=trailing

    It also has a property:

    [Description("Stop Type: 0=fixed, 1=trailing")]
    public int StopType
    {
    get { return stopType; }
    set { stopType = value; }
    }

    Now, in order to have the option to choose which stop type, I must have a property in my strategy that is shown in the property grid control.

    I have the following:


    [Description("Order Stop Type: 0=fixed, 1=trailing")]
    [GridCategory("Order Exit Parameters")]
    [RefreshProperties(RefreshProperties.All)]
    public int StopType
    {
    get { return order.StopType; }
    set { order.StopType = value; }
    }

    Where the variable order is an instance of my CoreOrder object which has already been instantiated. There is nothing recursive about it. I was wondering if the NinjaScript compiler does some regex matching or something to check that the property name and variable used inside are not of the same case or something and maybe it's incorrectly finding the field of the same name and thinking it's recursive? Is this a bug in the Ninjascript compiler?

    If you had something like:

    propertyName = "StopType";
    and propertyTarget = "order.StopType";

    and did a check like

    if ( System.Text.RegularExpressions.Regex.IsMatch(prope rtyTarget,propertyName,RegexOptions.None) )
    {
    // throw error about recursive properties
    }

    Then it would incorrectly identify my setup as recursive.

    If it is something I am doing wrong, I'd like to know and how the correct way to do it.

    Thanks,
    Josh

    #2
    That looks like it is trying to define the (object)order's StopType from order, which would be recursive.

    I think it might be more correct to simply define the startegy's StopType property as an unadorned integer, and then assign that value to the correct order property inside the code.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by cmtjoancolmenero, Yesterday, 03:58 PM
    1 response
    17 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by benmarkal, Yesterday, 12:52 PM
    3 responses
    23 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by helpwanted, Today, 03:06 AM
    1 response
    20 views
    0 likes
    Last Post sarafuenonly123  
    Started by Brevo, Today, 01:45 AM
    0 responses
    11 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    244 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Working...
    X