Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Shared class

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

    Shared class

    I'm sure there is a simple solution...(VB.NET guy)...

    I want to create a class I can call from all other strategies.

    namespace NinjaTrader.Strategy
    {
    partial class Strategy
    {
    }
    public class clsAccount
    {
    public void Check_OpenOrders()
    {

    }
    }
    }

    In my Strategy I have:

    clsAccount Acct = new clsAccount();

    Acct.Check_OpenOrders;

    NT is flagging the semi-colon at the end of Acct.Check_OpenOrders;

    The error I'm getting is:
    Class member declaration expected.
    Invalid token ";" in class, struct, or interface member declaration.

    It makes no difference if my class is within the "partial class Strategy" brackets or not...

    Thanks!
    Last edited by SteveB; 12-20-2008, 09:39 AM.

    #2
    just after a quick look.

    dont you need a () at the end since Check_OpenOrders() is a function?
    mrlogik
    NinjaTrader Ecosystem Vendor - Purelogik Trading

    Comment


      #3
      Sorry, I did try that before...the error message with "()" is:

      Invalid token "(" in class, struct, or interface member declaration.

      Comment


        #4
        I do count 7 curly braces in total, 1 seems to be missing.

        Regards
        Ralph

        Comment


          #5
          I appreciate everyone's help; it's not a bracket thing...just conveying my simple problem...

          I can't believe something this simple is so difficult.

          VB.Net guy

          Comment


            #6
            I made a GlobalVariables Indicator and posted it on this forum a few months ago. Since, I have also made a GlobalStrategy Strategy for use of global variables within strategies.

            Take a look at the attached.

            I have in here Set / Get methods for support / resistance values, but this can easily be changed for what you want.

            You can reference this for aid, as well as this.

            good luck.
            mrlogik
            NinjaTrader Ecosystem Vendor - Purelogik Trading

            Comment


              #7
              Hi Steve,

              it is not a simple problem, because your code works, with the syntax as proposed by mrlogik.

              It doesn't matter if one defines the clsAccount-class inside the the Strategy-class or just in the NinjaTrader.Strategy-namespace.
              It is possible to call Acct.Check_OpenOrders() in Initialize() for example.

              ... but it doesn't work to apply Acct.Check_OpenOrders() outside a class-method and that raises the same error message you mentioned.
              Is that your problem?

              Regards
              Ralph

              Comment


                #8
                Thank You Ralph!

                Yes I was putzing just to get an example up and running and had the code outside a class.

                Inside works like a charm.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by f.saeidi, Today, 12:14 PM
                4 responses
                12 views
                0 likes
                Last Post f.saeidi  
                Started by Russ Moreland, Today, 12:54 PM
                1 response
                6 views
                0 likes
                Last Post NinjaTrader_Erick  
                Started by philmg, Today, 12:55 PM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_ChristopherJ  
                Started by TradeForge, 04-19-2024, 02:09 AM
                2 responses
                32 views
                0 likes
                Last Post TradeForge  
                Started by aprilfool, 12-03-2022, 03:01 PM
                3 responses
                329 views
                0 likes
                Last Post NinjaTrader_Adrian  
                Working...
                X