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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        87 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        47 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        66 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        69 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        59 views
        0 likes
        Last Post CarlTrading  
        Working...
        X