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 charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        60 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        148 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        162 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        97 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        284 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X