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 AaronKoRn, Today, 09:49 PM
    0 responses
    6 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Today, 08:42 PM
    0 responses
    9 views
    0 likes
    Last Post carnitron  
    Started by strategist007, Today, 07:51 PM
    0 responses
    10 views
    0 likes
    Last Post strategist007  
    Started by StockTrader88, 03-06-2021, 08:58 AM
    44 responses
    3,976 views
    3 likes
    Last Post jhudas88  
    Started by rbeckmann05, Today, 06:48 PM
    0 responses
    9 views
    0 likes
    Last Post rbeckmann05  
    Working...
    X