Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How do I reference UserDefinedMethods code from inside a struct in strategy

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

    How do I reference UserDefinedMethods code from inside a struct in strategy

    I have scripted a struct in my strategy to gather lots of variables in one place which makes it easier to code with them and I have coded some methods into it as well, and I want to access a utility function I have written in UserDefinedMethods but the compiler complains:

    Code:
    Cannot access a non-static member of outer type 'NinjaTrader.Strategy.Strategy' via nested type 'NinjaTrader.Strategy.TrendFollower009.OrderStruct'    CS0038
    I'm not well trained in C# but I do know javascript, however here it's not much help. I'm using the utility methods extensively in a couple of other strategies, so I'd rather not change that - hopefully there's a way of coding for the utility function from within the struct - can you give some advice?

    Thanks

    #2
    Hello,

    I will have someone reply to you on Monday. Thank you for your patience.
    DenNinjaTrader Customer Service

    Comment


      #3
      adamus, unfortunately this is more general C# and hence outside of what scope we can support here - it sounds to me like you would need to check into set access modifiers in your scripts - http://msdn.microsoft.com/en-us/library/ms173121.aspx

      Comment


        #4
        Hi Bertrand,

        thanks for the link - I figured out that I was inadvertantly casting the Strategy object itself to StrategyBase in the method signature, for reasons long forgotten. Once I cast it to Strategy, the accessibility was there again.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        649 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        370 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        109 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        574 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        576 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X