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

The non-generic type 'System.ValueTuple' cannot be used with type arguments

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

    The non-generic type 'System.ValueTuple' cannot be used with type arguments

    I have this problem.

    Code:
    public class MyIndicator: Indicator {
    
    ​ // Declare a public field for the ValueTuple
    private ValueTuple<
    double, double, TimeSpan, TimeSpan,
    double, double, TimeSpan, TimeSpan,
    double, double, TimeSpan, TimeSpan,
    double, double, TimeSpan, TimeSpan,
    TimeSpan, TimeSpan, TimeSpan, TimeSpan> MyTuple;
    ​
    when trying to use that, I get the error:
    The non-generic type 'System.ValueTuple' cannot be used with type arguments
    ​I want to declare all those doubles and TimeSpans before the scope of OnBarUpdate.
    Then just set them in OnBarUpdate with:


    Code:
    MyTuple = new ValueTuple< double, double, TimeSpan, TimeSpan, double, double, TimeSpan, TimeSpan, double, double, TimeSpan, TimeSpan, double, double, TimeSpan, TimeSpan, TimeSpan, TimeSpan, TimeSpan, TimeSpan>(
    0.5, 0.5, new TimeSpan(1, 15, 0), new TimeSpan(0, 30, 0),
    0.8, 0.4, new TimeSpan(2, 30, 0), new TimeSpan(7, 45, 0),
    1.0, 1.1, new TimeSpan(1, 0, 0), new TimeSpan(3, 15, 0),
    6.3, 7.4, new TimeSpan(7, 15, 0), new TimeSpan(2, 30, 0),
    new TimeSpan(1, 45, 0), new TimeSpan(1, 0, 0),
    new TimeSpan(0, 15, 0), new TimeSpan(0, 30, 0) );​
    What am I doing wrong?

    Thank you very much ahead of time!

    #2
    Hello davydhnz,

    NinjaTrader uses C# 5 which does not have tuples.

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      NinjaTrader_ChelseaB,

      I've used them before in Ninja successfully with dictionaries like:

      Code:
      Dictionary<DateTime, Tuple<string, string, double>> myStopDictionary = new Dictionary<DateTime, Tuple<string, string, double>>();
      I was just looking for a way to set multiple doubles and timespans so that I can write the values without naming them, because I have some very repeative code, and this will make the code far more concise and less bloaty. Like 1, 6, new TimeSpan(1, 15, 0), instead of double nameone 1, double nametwo, 6, TimeSpan namethree == new TimeSpan(1, 15, 0)

      I'm just looking for a way to do it outside of a Dictionary.

      Thanks again.
      Last edited by davydhnz; 09-21-2023, 07:23 AM.

      Comment


        #4
        Hello davydhnz,

        Unfortunately, I would not be able to provide further information, as my understanding is that tuples require c# 7 or higher.

        This thread will remain open for any community members that can provide better information.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          NinjaTrader_ChelseaB,

          no worries. I worked it out in the end,
          but you have been so helpful to me numerous times on this forum. Have a lovely day!
          Last edited by davydhnz; 09-21-2023, 09:09 AM. Reason: it's past 3am where I live and I made an unforgivable typo. ‍♂️

          Comment


            #6
            try:

            Code:
            var data = Tuple.Create("EURUSD", 1.12345, DateTime.Now);
            string symbol = data.Item1;
            double price = data.Item2;
            DateTime timestamp = data.Item3;
            Print("String " + symbol + " Value " + price + " Time " + timestamp);

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by alexstox, 10-16-2018, 03:29 PM
            11 responses
            342 views
            0 likes
            Last Post aligator  
            Started by ageeholdings, 05-01-2024, 05:22 AM
            6 responses
            43 views
            0 likes
            Last Post ageeholdings  
            Started by tony_28217, Today, 07:04 PM
            0 responses
            11 views
            0 likes
            Last Post tony_28217  
            Started by flybuzz, Today, 10:33 AM
            1 response
            9 views
            0 likes
            Last Post flybuzz
            by flybuzz
             
            Started by spencerp92, 10-10-2023, 09:56 AM
            4 responses
            310 views
            0 likes
            Last Post flybuzz
            by flybuzz
             
            Working...
            X