![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| Automated Trading Support for automated trading systems using NinjaScript. Support for our ATI (Automated Trading Interface) used to link an external application such as TradeStation and eSignal to NinjaTrader. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Junior Member
Join Date: Nov 2011
Posts: 11
Thanks: 0
Thanked 1 time in 1 post
|
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 |
|
Senior Member
|
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. |
|
|
|
|
The following user says thank you to koganam for this post: |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Error in strategy - incorrect entries and exits on next bar | Zigman | Strategy Development | 4 | 04-02-2012 11:01 AM |
| Recursive Property Error ?? | AresBowman | Strategy Development | 3 | 06-17-2010 11:23 AM |
| Funny error when changing chart properties | noincomenojobnoassets | Version 7 Beta General Questions & Bug Reports | 4 | 04-20-2010 04:25 AM |
| recursive parameter error | junkone | General Programming | 2 | 11-20-2008 07:08 AM |
| Recursive Properties | zoltran | General Programming | 3 | 05-07-2008 01:29 AM |