Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Error CS0542 for Overloading and Optional Argument converting NT7 code to N8

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

    Error CS0542 for Overloading and Optional Argument converting NT7 code to N8

    I use Overloading and Optional Argument converting in a class to centralize different kinds of data to be operated. I know that C# 4.5 extended this option so I don't understand why I run into this compiler error CS0081 (Type parameter declaration must be an identifier not type). I would appreciate any suggestion.

    Here are the NT8 code and the NT7 code below it.

    Code:
    		
    // NT8 code that cases error CS0542
    		public class @Logic_DataVal
    		{
    			//// Input variables
    			private @Logic_DataType dataType;
    			// DataSeries
    			private Series<double> longValues;
    			private Series<double> shortValues;
    			private int displacement; // (>=0)
    			// Fix Value
    			private double fixValue;
    			// Price
    			private @Logic_PriceType longPriceType;
    			private @Logic_PriceType shortPriceType;
    			private int lookback; // (>=1)
    			//
    			private Indicator parentClass; 
    			
    			// @Logic_DataVal Constructor
    			public @Logic_DataVal(Indicator parentClass)
    			{
    				this.parentClass = parentClass;
    			}
    
    			// DataSeries Setup
    			public @Logic_DataVal Series<double>(Series<double> longValues, Series<double> shortValues)
    			{
    				return Series<double>(longValues, shortValues, 0);
    			}
    			public @Logic_DataVal Series<double>(Series<double> longValues, Series<double> shortValues, int displacement)
    			{
    				this.dataType = @Logic_DataType.DataSeries;
    				// DataSeries
    				this.longValues = longValues;
    				this.shortValues = shortValues;
    				this.displacement = displacement; // (>=0)
    				// Fix Value
    				this.fixValue = 0;
    				// Price
    				this.longPriceType = @Logic_PriceType.Close;
    				this.shortPriceType = @Logic_PriceType.Close;
    				this.lookback = 0; // (>=1)
    				return this;
    			}
    			
    			// Fix Value Setup
    			public @Logic_DataVal FixValue(double fixValue)
    			{
    				this.dataType = @Logic_DataType.FixValue;
    				// Fix Value
    				this.fixValue = fixValue;
    				// DataSeries
    				this.longValues = null;
    				this.shortValues = null;
    				this.displacement = 0;
    				// Price
    				this.longPriceType = @Logic_PriceType.Close;
    				this.shortPriceType = @Logic_PriceType.Close;
    				this.lookback = 0; // (>=1)
    				return this;
    			}
    			
    			// Price Setup
    			public @Logic_DataVal Price(@Logic_PriceType longPriceType, @Logic_PriceType shortPriceType, int lookback)
    			{
    				this.dataType = @Logic_DataType.Price;
    				// Price
    				this.longPriceType = longPriceType;
    				this.shortPriceType = shortPriceType;
    				this.lookback = lookback; // (>=1)
    				// DataSeries
    				this.longValues = null;
    				this.shortValues = null;
    				this.displacement = 0;
    				// Fix Value
    				this.fixValue = 0;
    				return this;
    			}
    ...
    				}
    				return value;
    			}
    		}
    Here is the original NT7 code:
    Code:
    // NT7 code
    public class @Logic_DataVal
    		{
    			//// Input variables
    			private @Logic_DataType dataType;
    			// DataSeries
    			private DataSeries longValues;
    			private DataSeries shortValues;
    			private int displacement; // (>=0)
    			// Fix Value
    			private double fixValue;
    			// Price
    			private @Logic_PriceType longPriceType;
    			private @Logic_PriceType shortPriceType;
    			private int lookback; // (>=1)
    			//
    			private Indicator parentClass; 
    			
    			// @Logic_DataVal Constructor
    			public @Logic_DataVal(Indicator parentClass)
    			{
    				this.parentClass = parentClass;
    			}
    
    			// DataSeries Setup
    			public @Logic_DataVal DataSeries(DataSeries longValues, DataSeries shortValues)
    			{
    				return DataSeries(longValues, shortValues, 0);
    			}
    			public @Logic_DataVal DataSeries(DataSeries longValues, DataSeries shortValues, int displacement)
    			{
    				this.dataType = @Logic_DataType.DataSeries;
    				// DataSeries
    				this.longValues = longValues;
    				this.shortValues = shortValues;
    				this.displacement = displacement; // (>=0)
    				// Fix Value
    				this.fixValue = 0;
    				// Price
    				this.longPriceType = @Logic_PriceType.Close;
    				this.shortPriceType = @Logic_PriceType.Close;
    				this.lookback = 0; // (>=1)
    				return this;
    			}
    			
    			// Fix Value Setup
    			public @Logic_DataVal FixValue(double fixValue)
    			{
    				this.dataType = @Logic_DataType.FixValue;
    				// Fix Value
    				this.fixValue = fixValue;
    				// DataSeries
    				this.longValues = null;
    				this.shortValues = null;
    				this.displacement = 0;
    				// Price
    				this.longPriceType = @Logic_PriceType.Close;
    				this.shortPriceType = @Logic_PriceType.Close;
    				this.lookback = 0; // (>=1)
    				return this;
    			}
    			
    			// Price Setup
    			public @Logic_DataVal Price(@Logic_PriceType longPriceType, @Logic_PriceType shortPriceType, int lookback)
    			{
    				this.dataType = @Logic_DataType.Price;
    				// Price
    				this.longPriceType = longPriceType;
    				this.shortPriceType = shortPriceType;
    				this.lookback = lookback; // (>=1)
    				// DataSeries
    				this.longValues = null;
    				this.shortValues = null;
    				this.displacement = 0;
    				// Fix Value
    				this.fixValue = 0;
    				return this;
    			}
    			
    			// return the long Value
    			public double GetLong()
    			{
    				return GetLong(0);
    			}
    
    ...
    				}
    				return value;
    			}
    		}
    Last edited by Shai Samuel; 08-21-2017, 09:13 PM.

    #2
    Hello Shai Samuel,

    Thank you for your post.

    What line is reported for the compile error? Can you attach a screenshot of the error after double clicking on the error to highlight the offending line of code?

    To send a screenshot with Windows 7 or newer I would recommend using Window's Snipping Tool.

    Click here for instructions: http://windows.microsoft.com/en-us/w...#1TC=windows-8

    Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file and send the file as an attachment.

    Click here for detailed instruction: http://take-a-screenshot.org/

    I look forward to your response.

    Comment


      #3
      Thank you Patrick, attach is the screen.
      Attached Files

      Comment


        #4
        Hello Shai,

        It appears that you are using an invalid naming convention for your method. The proper syntax is below.
        public Series<double> MyMethodName(Series<double> var1, series<double> var2)

        You could remove the "<double>" in Series<double> and you would have a valid name.

        The following links are the naming guidelines methods



        Let me know if you have any more questions about this.
        Last edited by NinjaTrader_JoshG; 08-22-2017, 01:00 PM.
        Josh G.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by The_Sec, Yesterday, 03:37 PM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by vecnopus, Today, 06:15 AM
        0 responses
        1 view
        0 likes
        Last Post vecnopus  
        Started by Aviram Y, Today, 05:29 AM
        0 responses
        5 views
        0 likes
        Last Post Aviram Y  
        Started by quantismo, 04-17-2024, 05:13 PM
        3 responses
        27 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by ScottWalsh, 04-16-2024, 04:29 PM
        7 responses
        36 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Working...
        X