Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            602 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            347 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            560 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            559 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X