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 SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        50 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        22 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        16 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        22 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        23 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X