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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        42 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        20 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        29 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        46 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        38 views
        0 likes
        Last Post CarlTrading  
        Working...
        X