Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Class member declaration expected

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

    Class member declaration expected

    I'm getting this error for this line, but it doesn't prevent compile, it just shows as an error until I compile - and it works. What's it complaining about?

    private Dictionary<(marketConditionName, double), marketConditionPerformanceTracker> marketConditionScoring = new Dictionary<(marketConditionName, double), marketConditionPerformanceTracker>();

    #2
    Hello Skifree,

    That is due to the dictionary parameters. While that is valid in C# the NinjaScript editor sees that as invalid due to the parenthesis in the dictionary type. ere you trying to use a tuple as the key? If so that needs to be defined like the following to avoid that error:

    Code:
    private Dictionary<Tuple<marketConditionName, double>, marketConditionPerformanceTracker> marketConditionScoring = new Dictionary<Tuple<marketConditionName, double>, marketConditionPerformanceTracker>();

    Comment


      #3
      Correct the tuple is a key, effectively a third column in the dictionary

      Comment


        #4
        Hello Skifree,

        Thanks for confirming. You should be able to use the code I provided in my last reply for that use case. You just need to use the format Tuple<T,T> instead.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CaptainJack, 05-29-2026, 05:09 AM
        0 responses
        163 views
        0 likes
        Last Post CaptainJack  
        Started by CaptainJack, 05-29-2026, 12:02 AM
        0 responses
        83 views
        0 likes
        Last Post CaptainJack  
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        126 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        206 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        185 views
        0 likes
        Last Post CarlTrading  
        Working...
        X